| Conditions | 9 |
| Paths | 11 |
| Total Lines | 52 |
| Code Lines | 33 |
| Lines | 23 |
| Ratio | 44.23 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 47 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
||
| 48 | { |
||
| 49 | $tokens = $phpcsFile->getTokens(); |
||
| 50 | $token = $tokens[$stackPtr]; |
||
| 51 | |||
| 52 | if ($this->couldBeBinaryInteger($tokens, $stackPtr) === true) { |
||
| 53 | if ($this->supportsBelow('5.3')) { |
||
| 54 | $error = 'Binary integer literals were not present in PHP version 5.3 or earlier. Found: %s'; |
||
| 55 | if ($this->isLowPHPVersion === false) { |
||
| 56 | $data = array($token['content']); |
||
| 57 | } |
||
| 58 | else { |
||
| 59 | $data = array($this->getBinaryInteger($phpcsFile, $tokens, $stackPtr)); |
||
| 60 | } |
||
| 61 | $phpcsFile->addError($error, $stackPtr, 'BinaryIntegerFound', $data); |
||
| 62 | } |
||
| 63 | |||
| 64 | if ($this->isInvalidBinaryInteger($tokens, $stackPtr) === true) { |
||
| 65 | $error = 'Invalid binary integer detected. Found: %s'; |
||
| 66 | $data = array($this->getBinaryInteger($phpcsFile, $tokens, $stackPtr)); |
||
| 67 | $phpcsFile->addError($error, $stackPtr, 'InvalidBinaryIntegerFound', $data); |
||
| 68 | } |
||
| 69 | return; |
||
| 70 | } |
||
| 71 | |||
| 72 | $data = array( $token['content'] ); |
||
| 73 | View Code Duplication | if ($this->isInvalidOctalInteger($tokens, $stackPtr) === true) { |
|
|
1 ignored issue
–
show
|
|||
| 74 | $error = 'Invalid octal integer detected. Prior to PHP 7 this would lead to a truncated number. From PHP 7 onwards this causes a parse error. Found: %s'; |
||
| 75 | $isError = $this->supportsAbove('7.0'); |
||
| 76 | |||
| 77 | if ($isError === true) { |
||
| 78 | $phpcsFile->addError($error, $stackPtr, 'InvalidOctalIntegerFound', $data); |
||
| 79 | } else { |
||
| 80 | $phpcsFile->addWarning($error, $stackPtr, 'InvalidOctalIntegerFound', $data); |
||
| 81 | } |
||
| 82 | |||
| 83 | return; |
||
| 84 | } |
||
| 85 | |||
| 86 | View Code Duplication | if ($this->isHexidecimalNumericString($tokens, $stackPtr) === true) { |
|
|
1 ignored issue
–
show
|
|||
| 87 | $error = 'The behaviour of hexadecimal numeric strings was inconsistent prior to PHP 7 and support has been removed in PHP 7. Found: %s'; |
||
| 88 | $isError = $this->supportsAbove('7.0'); |
||
| 89 | |||
| 90 | if ($isError === true) { |
||
| 91 | $phpcsFile->addError($error, $stackPtr, 'HexNumericStringFound', $data); |
||
| 92 | } else { |
||
| 93 | $phpcsFile->addWarning($error, $stackPtr, 'HexNumericStringFound', $data); |
||
| 94 | } |
||
| 95 | return; |
||
| 96 | } |
||
| 97 | |||
| 98 | }//end process() |
||
| 99 | |||
| 209 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.