Skip to content

Commit

Permalink
Merge pull request #161 from msamgan/refactortoring
Browse files Browse the repository at this point in the history
Refactortoring
  • Loading branch information
driftingly authored Oct 9, 2024
2 parents 519dbcc + 05aa096 commit 8f4746a
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 39 deletions.
2 changes: 1 addition & 1 deletion app/Actions/Clean.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Actions;

use App\Support\Tool;
use App\Contracts\Tool;
use Illuminate\Console\Command;

class Clean
Expand Down
4 changes: 2 additions & 2 deletions app/Commands/FixCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Commands;

use App\Support\ConfiguresForLintOrFix;
use App\Support\GetsCleaner;
use App\Concerns\ConfiguresForLintOrFix;
use App\Concerns\GetsCleaner;
use Exception;
use LaravelZero\Framework\Commands\Command;
use LaravelZero\Framework\Exceptions\ConsoleException;
Expand Down
4 changes: 2 additions & 2 deletions app/Commands/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Commands;

use App\Support\ConfiguresForLintOrFix;
use App\Support\GetsCleaner;
use App\Concerns\ConfiguresForLintOrFix;
use App\Concerns\GetsCleaner;
use Exception;
use LaravelZero\Framework\Commands\Command;
use LaravelZero\Framework\Exceptions\ConsoleException;
Expand Down
10 changes: 10 additions & 0 deletions app/Concerns/CommandHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@ public function success(string $message): void
{
render('<div class="text-green-900 bg-green-300 px-1 font-bold">>> success: ' . $message . '</div>');
}

public function heading(string $heading): void
{
render('<div class="font-bold bg-yellow-800 px-1">=> ' . $heading . '</div>');
}

public function failure(string $message): void
{
render('<div class="text-red-900 bg-red-300 px-1 font-bold">!! error: ' . $message . '</div>');
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Support;
namespace App\Concerns;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
Expand Down
9 changes: 8 additions & 1 deletion app/Support/GetsCleaner.php → app/Concerns/GetsCleaner.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<?php

namespace App\Support;
namespace App\Concerns;

use App\Actions\Clean;
use App\Contracts\Tool;
use App\Support\DusterConfig;
use App\Support\PhpCodeSniffer;
use App\Support\PhpCsFixer;
use App\Support\Pint;
use App\Support\TLint;
use App\Support\UserScript;

trait GetsCleaner
{
Expand Down
19 changes: 19 additions & 0 deletions app/Contracts/Tool.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Contracts;

use App\Concerns\CommandHelpers;
use App\Support\DusterConfig;

abstract class Tool
{
use CommandHelpers;

public function __construct(
protected DusterConfig $dusterConfig,
) {}

abstract public function lint(): int;

abstract public function fix(): int;
}
1 change: 1 addition & 0 deletions app/Support/PhpCodeSniffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Support;

use App\Contracts\Tool;
use App\Project;
use PHP_CodeSniffer\Config;
use PHP_CodeSniffer\Runner;
Expand Down
2 changes: 1 addition & 1 deletion app/Support/PhpCsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace App\Support;

use App\Actions\ElaborateSummary;
use App\Contracts\Tool;
use App\Project;
use ArrayIterator;
use PhpCsFixer\Config;
use PhpCsFixer\ConfigInterface;
use PhpCsFixer\ConfigurationException\InvalidConfigurationException;
use PhpCsFixer\Console\ConfigurationResolver;
Expand Down
1 change: 1 addition & 0 deletions app/Support/Pint.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Actions\ElaborateSummary;
use App\Actions\FixCode;
use App\Commands\DefaultCommand;
use App\Contracts\Tool;

class Pint extends Tool
{
Expand Down
1 change: 1 addition & 0 deletions app/Support/TLint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Support;

use App\Contracts\Tool;
use Illuminate\Console\Command;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
Expand Down
31 changes: 0 additions & 31 deletions app/Support/Tool.php

This file was deleted.

1 change: 1 addition & 0 deletions app/Support/UserScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Support;

use App\Contracts\Tool;
use Illuminate\Console\Command;
use JsonException;
use Psr\Container\ContainerExceptionInterface;
Expand Down

0 comments on commit 8f4746a

Please sign in to comment.