| Conditions | 2 |
| Paths | 2 |
| Total Lines | 84 |
| Code Lines | 50 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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 |
||
| 29 | public function testScannerTokenizesDocBlockWhitConstants() |
||
| 30 | { |
||
| 31 | $lexer = new DocLexer(); |
||
| 32 | $docblock = '@AnnotationWithConstants(PHP_EOL, ClassWithConstants::SOME_VALUE, ClassWithConstants::CONSTANT_, ClassWithConstants::CONST_ANT3, \Doctrine\Tests\Annotations\Fixtures\InterfaceWithConstants::SOME_VALUE)'; |
||
| 33 | |||
| 34 | $tokens = [ |
||
| 35 | [ |
||
| 36 | 'value' => '@', |
||
| 37 | 'position' => 0, |
||
| 38 | 'type' => DocLexer::T_AT, |
||
| 39 | ], |
||
| 40 | [ |
||
| 41 | 'value' => 'AnnotationWithConstants', |
||
| 42 | 'position' => 1, |
||
| 43 | 'type' => DocLexer::T_IDENTIFIER, |
||
| 44 | ], |
||
| 45 | [ |
||
| 46 | 'value' => '(', |
||
| 47 | 'position' => 24, |
||
| 48 | 'type' => DocLexer::T_OPEN_PARENTHESIS, |
||
| 49 | ], |
||
| 50 | [ |
||
| 51 | 'value' => 'PHP_EOL', |
||
| 52 | 'position' => 25, |
||
| 53 | 'type' => DocLexer::T_IDENTIFIER, |
||
| 54 | ], |
||
| 55 | [ |
||
| 56 | 'value' => ',', |
||
| 57 | 'position' => 32, |
||
| 58 | 'type' => DocLexer::T_COMMA, |
||
| 59 | ], |
||
| 60 | [ |
||
| 61 | 'value' => 'ClassWithConstants::SOME_VALUE', |
||
| 62 | 'position' => 34, |
||
| 63 | 'type' => DocLexer::T_IDENTIFIER, |
||
| 64 | ], |
||
| 65 | [ |
||
| 66 | 'value' => ',', |
||
| 67 | 'position' => 64, |
||
| 68 | 'type' => DocLexer::T_COMMA, |
||
| 69 | ], |
||
| 70 | [ |
||
| 71 | 'value' => 'ClassWithConstants::CONSTANT_', |
||
| 72 | 'position' => 66, |
||
| 73 | 'type' => DocLexer::T_IDENTIFIER, |
||
| 74 | ], |
||
| 75 | [ |
||
| 76 | 'value' => ',', |
||
| 77 | 'position' => 95, |
||
| 78 | 'type' => DocLexer::T_COMMA, |
||
| 79 | ], |
||
| 80 | [ |
||
| 81 | 'value' => 'ClassWithConstants::CONST_ANT3', |
||
| 82 | 'position' => 97, |
||
| 83 | 'type' => DocLexer::T_IDENTIFIER, |
||
| 84 | ], |
||
| 85 | [ |
||
| 86 | 'value' => ',', |
||
| 87 | 'position' => 127, |
||
| 88 | 'type' => DocLexer::T_COMMA, |
||
| 89 | ], |
||
| 90 | [ |
||
| 91 | 'value' => '\\Doctrine\\Tests\\Annotations\\Fixtures\\InterfaceWithConstants::SOME_VALUE', |
||
| 92 | 'position' => 129, |
||
| 93 | 'type' => DocLexer::T_IDENTIFIER, |
||
| 94 | ], |
||
| 95 | [ |
||
| 96 | 'value' => ')', |
||
| 97 | 'position' => 200, |
||
| 98 | 'type' => DocLexer::T_CLOSE_PARENTHESIS, |
||
| 99 | ] |
||
| 100 | ]; |
||
| 101 | |||
| 102 | $lexer->setInput($docblock); |
||
| 103 | |||
| 104 | foreach ($tokens as $expected) { |
||
| 105 | $lexer->moveNext(); |
||
| 106 | $lookahead = $lexer->lookahead; |
||
| 107 | self::assertEquals($expected['value'], $lookahead['value']); |
||
| 108 | self::assertEquals($expected['type'], $lookahead['type']); |
||
| 109 | self::assertEquals($expected['position'], $lookahead['position']); |
||
| 110 | } |
||
| 111 | |||
| 112 | self::assertFalse($lexer->moveNext()); |
||
| 113 | } |
||
| 218 |