Skip to content

Commit

Permalink
use is*Error() methods
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Oct 30, 2023
1 parent 0e8f202 commit c81e862
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/BaselineAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,34 +142,28 @@ private function countClassesComplexity(BaselineError $baselineError): int

private function countInvalidPhpdocs(BaselineError $baselineError): int
{
return str_contains($baselineError->message, 'PHPDoc tag ')
return $baselineError->isInvalidPhpDocError()
? $baselineError->count
: 0;
}

private function countUnknownTypes(BaselineError $baselineError): int
{
$notFoundCount = preg_match('/Instantiated class .+ not found/', $baselineError->message, $matches) === 1
return $baselineError->isUnknownTypeError()
? $baselineError->count
: 0;

$unknownCount = str_contains($baselineError->message, 'on an unknown class') || str_contains($baselineError->message, 'has invalid type unknown') || str_contains($baselineError->message, 'unknown_type as its type')
? $baselineError->count
: 0;

return $notFoundCount + $unknownCount;
}

private function countAnonymousVariables(BaselineError $baselineError): int
{
return str_contains($baselineError->message, 'Anonymous variable')
return $baselineError->isAnonymousVariableError()
? $baselineError->count
: 0;
}

private function countUnusedSymbols(BaselineError $baselineError): int
{
return str_ends_with($baselineError->message, 'is never used$#')
return $baselineError->isUnusedSymbolError()
? $baselineError->count
: 0;
}
Expand Down

0 comments on commit c81e862

Please sign in to comment.