Skip to content

Commit

Permalink
Add remove extra semi colons command
Browse files Browse the repository at this point in the history
  • Loading branch information
imanghafoori1 committed Jul 28, 2024
1 parent 048143d commit 1e80aca
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Commands/CheckExtraSemiColons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Imanghafoori\LaravelMicroscope\Commands;

use Illuminate\Console\Command;
use Imanghafoori\LaravelMicroscope\ErrorReporters\ErrorPrinter;
use Imanghafoori\LaravelMicroscope\Traits\LogsErrors;
use JetBrains\PhpStorm\ExpectedValues;

class CheckExtraSemiColons extends Command
{
use LogsErrors;
use PatternApply;

protected $signature = 'check:extra_semi_colons
{--f|file=}
{--d|folder=}
{--nofix}';

protected $description = 'Removes extra semi-colons.';

protected $customMsg = 'No extra semi-colons were found. \(^_^)/';

#[ExpectedValues(values: [0, 1])]
public function handle(ErrorPrinter $errorPrinter)
{
event('microscope.start.command');
$this->info('Soaring like an eagle...');

return $this->patternCommand($errorPrinter);
}

public function getPatterns()
{
return [
'remove_extra_semi_colons' => [
'cacheKey' => 'extra_semi_colons-v1',
'search' => ';;',
'replace' => $this->option('nofix') ? null : ';',
],
];
}
}
1 change: 1 addition & 0 deletions src/ServiceProvider/CommandsRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ trait CommandsRegistry
Commands\CheckDynamicWhereMethod::class,
Features\ListModels\ListModelsArtisanCommand::class,
Commands\CheckEmptyComments::class,
Commands\CheckExtraSemiColons::class,
];

private function registerCommands()
Expand Down

0 comments on commit 1e80aca

Please sign in to comment.