forked from squizlabs/PHP_CodeSniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calculate CYC for PHP 8 match() expression in Cyclomatic Complexity sniff
- Loading branch information
MarkBaker
committed
Nov 12, 2021
1 parent
5fb9b64
commit 2989b0d
Showing
4 changed files
with
61 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.3.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
function complexityFiveWithMatch() | ||
{ | ||
return match(strtolower(substr($monthName, 0, 3))){ | ||
'apr', 'jun', 'sep', 'nov' => 30, | ||
'jan', 'mar', 'may', 'jul', 'aug', 'oct', 'dec' => 31, | ||
'feb' => is_leap($year) ? 29 : 28, | ||
default => throw new InvalidArgumentException("Bogus month"), | ||
} | ||
} | ||
|
||
function complexityFourteenWithMatch() | ||
{ | ||
return match(strtolower(substr($monthName, 0, 3))) { | ||
'jan' => 31, | ||
'feb' => is_leap($year) ? 29 : 28, | ||
'mar' => 31, | ||
'apr' => 30, | ||
'may' => 31, | ||
'jun' => 30, | ||
'jul' => 31, | ||
'aug' => 31, | ||
'sep' => 30, | ||
'oct' => 31, | ||
'nov' => 30, | ||
'dec' => 31, | ||
default => throw new InvalidArgumentException("Bogus month"), | ||
}; | ||
} | ||
|
||
?> |
160 changes: 0 additions & 160 deletions
160
src/Standards/Generic/Tests/Metrics/CyclomaticComplexityUnitTest.inc
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters