Skip to content

Commit ffa4892

Browse files
committed
Using $name as property
1 parent 805c843 commit ffa4892

File tree

4 files changed

+41
-30
lines changed

4 files changed

+41
-30
lines changed

src/Console/Commands/Hooks/BaseCodeAnalyzerPreCommitHook.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ abstract class BaseCodeAnalyzerPreCommitHook
2222
*/
2323
public $command;
2424

25+
/**
26+
* Name of the hook
27+
* @var string
28+
*/
29+
protected $name;
30+
2531
/*
2632
* List of files extensions that will be analyzed by the hook.
2733
* Can also be a regular expression.
@@ -183,6 +189,14 @@ protected function suggestAutoFixOrExit()
183189
}
184190
}
185191

192+
/**
193+
* Get the name of the hook.
194+
*/
195+
public function getName(): ?string
196+
{
197+
return $this->name;
198+
}
199+
186200
/**
187201
* @param array|string $fileExtensions
188202
* @return BaseCodeAnalyzerPreCommitHook

src/Console/Commands/Hooks/BladeFormatterPreCommitHook.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ class BladeFormatterPreCommitHook extends BaseCodeAnalyzerPreCommitHook implemen
1111
/**
1212
* @var string
1313
*/
14-
protected $analyzerConfigParam;
14+
protected $configParam;
1515

1616
/**
17-
* Get the name of the hook.
17+
* Name of the hook
18+
*
19+
* @var string
1820
*/
19-
public function getName(): ?string
20-
{
21-
return 'Blade Formatter';
22-
}
21+
protected $name = 'Blade Formatter';
2322

2423
/**
2524
* Analyze and fix committed blade.php files using blade-formatter npm package
@@ -30,7 +29,7 @@ public function getName(): ?string
3029
*/
3130
public function handle(ChangedFiles $files, Closure $next)
3231
{
33-
$this->analyzerConfigParam = $this->analyzerConfigParam();
32+
$this->configParam = $this->configParam();
3433

3534
return $this->setFileExtensions('/\.blade\.php$/')
3635
->setAnalyzerExecutable(config('git-hooks.code_analyzers.blade_formatter.path'), true)
@@ -42,15 +41,15 @@ public function handle(ChangedFiles $files, Closure $next)
4241
*/
4342
public function analyzerCommand(): string
4443
{
45-
return trim(sprintf('%s -c %s', $this->getAnalyzerExecutable(), $this->analyzerConfigParam));
44+
return trim(sprintf('%s -c %s', $this->getAnalyzerExecutable(), $this->configParam));
4645
}
4746

4847
/**
4948
* Returns the command to run Blade Formatter fixer
5049
*/
5150
public function fixerCommand(): string
5251
{
53-
return trim(sprintf('%s --write %s', $this->getFixerExecutable(), $this->analyzerConfigParam));
52+
return trim(sprintf('%s --write %s', $this->getFixerExecutable(), $this->configParam));
5453
}
5554

5655
/**
@@ -60,7 +59,7 @@ public function fixerCommand(): string
6059
*
6160
* @return string The configuration parameter for the analyzer.
6261
*/
63-
public function analyzerConfigParam(): string
62+
public function configParam(): string
6463
{
6564
$bladeFormatterConfig = rtrim(config('git-hooks.code_analyzers.blade_formatter.config'), '/');
6665

src/Console/Commands/Hooks/PHPCodeSnifferPreCommitHook.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ class PHPCodeSnifferPreCommitHook extends BaseCodeAnalyzerPreCommitHook implemen
1111
/**
1212
* @var string
1313
*/
14-
protected $analyzerConfigParam;
14+
protected $configParam;
1515

1616
/**
17-
* Get the name of the hook.
17+
* Name of the hook
18+
*
19+
* @var string
1820
*/
19-
public function getName(): ?string
20-
{
21-
return 'PHP_CodeSniffer';
22-
}
21+
protected $name = 'PHP_CodeSniffer';
2322

2423
/**
2524
* Analyze and fix committed PHP files using PHP Code Sniffer and PHP Code Beautifier and Fixer.
@@ -30,7 +29,7 @@ public function getName(): ?string
3029
*/
3130
public function handle(ChangedFiles $files, Closure $next)
3231
{
33-
$this->analyzerConfigParam = $this->analyzerConfigParam();
32+
$this->configParam = $this->configParam();
3433

3534
return $this->setFileExtensions(['php'])
3635
->setAnalyzerExecutable(config('git-hooks.code_analyzers.php_code_sniffer.phpcs_path'))
@@ -43,15 +42,15 @@ public function handle(ChangedFiles $files, Closure $next)
4342
*/
4443
public function analyzerCommand(): string
4544
{
46-
return trim(sprintf('%s %s', $this->getAnalyzerExecutable(), $this->analyzerConfigParam));
45+
return trim(sprintf('%s %s', $this->getAnalyzerExecutable(), $this->configParam));
4746
}
4847

4948
/**
5049
* Returns the command to run PHPCS
5150
*/
5251
public function fixerCommand(): string
5352
{
54-
return trim(sprintf('%s %s', $this->getFixerExecutable(), $this->analyzerConfigParam));
53+
return trim(sprintf('%s %s', $this->getFixerExecutable(), $this->configParam));
5554
}
5655

5756
/**
@@ -61,7 +60,7 @@ public function fixerCommand(): string
6160
*
6261
* @return string The configuration parameter for the analyzer.
6362
*/
64-
public function analyzerConfigParam(): string
63+
public function configParam(): string
6564
{
6665
$phpCSStandard = rtrim(config('git-hooks.code_analyzers.php_code_sniffer.standard'), '/');
6766

src/Console/Commands/Hooks/PintPreCommitHook.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ class PintPreCommitHook extends BaseCodeAnalyzerPreCommitHook implements CodeAna
1111
/**
1212
* @var string
1313
*/
14-
protected $analyzerConfigParam;
14+
protected $configParam;
1515

1616
/**
17-
* Get the name of the hook.
17+
* Name of the hook
18+
*
19+
* @var string
1820
*/
19-
public function getName(): ?string
20-
{
21-
return 'Laravel Pint';
22-
}
21+
protected $name = 'Laravel Pint';
2322

2423
/**
2524
* Analyze and fix committed PHP files using Laravel Pint
@@ -30,7 +29,7 @@ public function getName(): ?string
3029
*/
3130
public function handle(ChangedFiles $files, Closure $next)
3231
{
33-
$this->analyzerConfigParam = $this->analyzerConfigParam();
32+
$this->configParam = $this->configParam();
3433

3534
return $this->setFileExtensions(['php'])
3635
->setAnalyzerExecutable(config('git-hooks.code_analyzers.laravel_pint.path'), true)
@@ -42,23 +41,23 @@ public function handle(ChangedFiles $files, Closure $next)
4241
*/
4342
public function analyzerCommand(): string
4443
{
45-
return trim(sprintf('%s --test %s', $this->getAnalyzerExecutable(), $this->analyzerConfigParam));
44+
return trim(sprintf('%s --test %s', $this->getAnalyzerExecutable(), $this->configParam));
4645
}
4746

4847
/**
4948
* Returns the command to run Pint fixer
5049
*/
5150
public function fixerCommand(): string
5251
{
53-
return trim(sprintf('%s %s', $this->getFixerExecutable(), $this->analyzerConfigParam));
52+
return trim(sprintf('%s %s', $this->getFixerExecutable(), $this->configParam));
5453
}
5554

5655
/**
5756
* Gets the command-line parameter for specifying the configuration file for Laravel Pint.
5857
*
5958
* @return string The command-line parameter for the configuration file, or an empty string if not set.
6059
*/
61-
protected function analyzerConfigParam(): string
60+
protected function configParam(): string
6261
{
6362
$pintConfigFile = config('git-hooks.code_analyzers.laravel_pint.config');
6463

0 commit comments

Comments
 (0)