Making a Check
php artisan make:pheck Jobs/JobClassesMustHaveTheRightSuffixCheckclass JobClassesMustHaveTheRightSuffixCheck implements Check
{
public function __construct(
private readonly FileSource $source
) {}
/**
* Get Matches will fetch and filter all file
* matches that might be interesting for our Check.
*
* In this example, we get the Actions that match a
* pattern that checks for a class extending another class.
*/
public function getMatches(): MatchCollection
{
return $this->source
->directory('./app/Jobs')
->recursive()
->run();
}
/**
* Process Match will let you return an array of ViolationBuilders.
*
* @param FileMatch $match
*/
public function processMatch($match, FileMatch $file): array
{
if ($condition) {
// If you consider the Match does not need a
// violation, you can return an empty array.
return [];
}
return [
ViolationBuilder::make()
->message('Explain the problem here.')
->setUrl($wikiUrl),
];
}
}Installing the Check
Building the Violation
Last updated