Conditions | 17 |
Paths | 5 |
Total Lines | 38 |
Code Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 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 |
||
30 | public function parse(Parser $parser): void |
||
31 | { |
||
32 | $ormV2 = !\class_exists(TokenType::class); |
||
33 | |||
34 | $parser->match($ormV2 ? Lexer::T_IDENTIFIER : TokenType::T_IDENTIFIER); |
||
|
|||
35 | $parser->match($ormV2 ? Lexer::T_OPEN_PARENTHESIS : TokenType::T_OPEN_PARENTHESIS); |
||
36 | $this->sourceType = $parser->SimpleArithmeticExpression(); |
||
37 | $parser->match($ormV2 ? Lexer::T_AS : TokenType::T_AS); |
||
38 | $parser->match($ormV2 ? Lexer::T_IDENTIFIER : TokenType::T_IDENTIFIER); |
||
39 | |||
40 | $lexer = $parser->getLexer(); |
||
41 | $token = $lexer->token; |
||
42 | if (!$token instanceof Token) { |
||
43 | return; |
||
44 | } |
||
45 | if (!\is_string($token->value)) { |
||
46 | return; |
||
47 | } |
||
48 | |||
49 | $type = $token->value; |
||
50 | if ($lexer->isNextToken($ormV2 ? Lexer::T_OPEN_PARENTHESIS : TokenType::T_OPEN_PARENTHESIS)) { |
||
51 | $parser->match($ormV2 ? Lexer::T_OPEN_PARENTHESIS : TokenType::T_OPEN_PARENTHESIS); |
||
52 | $parameter = $parser->Literal(); |
||
53 | $parameters = [$parameter->value]; |
||
54 | if ($lexer->isNextToken($ormV2 ? Lexer::T_COMMA : TokenType::T_COMMA)) { |
||
55 | while ($lexer->isNextToken($ormV2 ? Lexer::T_COMMA : TokenType::T_COMMA)) { |
||
56 | $parser->match($ormV2 ? Lexer::T_COMMA : TokenType::T_COMMA); |
||
57 | $parameter = $parser->Literal(); |
||
58 | $parameters[] = $parameter->value; |
||
59 | } |
||
60 | } |
||
61 | $parser->match($ormV2 ? Lexer::T_CLOSE_PARENTHESIS : TokenType::T_CLOSE_PARENTHESIS); |
||
62 | $type .= '('.\implode(', ', $parameters).')'; |
||
63 | } |
||
64 | |||
65 | $this->targetType = $type; |
||
66 | |||
67 | $parser->match($ormV2 ? Lexer::T_CLOSE_PARENTHESIS : TokenType::T_CLOSE_PARENTHESIS); |
||
68 | } |
||
75 |