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 |
||
31 | public function parse(Parser $parser): void |
||
32 | { |
||
33 | $shouldUseLexer = DoctrineOrm::isPre219(); |
||
34 | |||
35 | $parser->match($shouldUseLexer ? Lexer::T_IDENTIFIER : TokenType::T_IDENTIFIER); |
||
|
|||
36 | $parser->match($shouldUseLexer ? Lexer::T_OPEN_PARENTHESIS : TokenType::T_OPEN_PARENTHESIS); |
||
37 | $this->sourceType = $parser->SimpleArithmeticExpression(); |
||
38 | $parser->match($shouldUseLexer ? Lexer::T_AS : TokenType::T_AS); |
||
39 | $parser->match($shouldUseLexer ? Lexer::T_IDENTIFIER : TokenType::T_IDENTIFIER); |
||
40 | |||
41 | $lexer = $parser->getLexer(); |
||
42 | $token = $lexer->token; |
||
43 | if (!$token instanceof Token) { |
||
44 | return; |
||
45 | } |
||
46 | if (!\is_string($token->value)) { |
||
47 | return; |
||
48 | } |
||
49 | |||
50 | $type = $token->value; |
||
51 | if ($lexer->isNextToken($shouldUseLexer ? Lexer::T_OPEN_PARENTHESIS : TokenType::T_OPEN_PARENTHESIS)) { |
||
52 | $parser->match($shouldUseLexer ? Lexer::T_OPEN_PARENTHESIS : TokenType::T_OPEN_PARENTHESIS); |
||
53 | $parameter = $parser->Literal(); |
||
54 | $parameters = [$parameter->value]; |
||
55 | if ($lexer->isNextToken($shouldUseLexer ? Lexer::T_COMMA : TokenType::T_COMMA)) { |
||
56 | while ($lexer->isNextToken($shouldUseLexer ? Lexer::T_COMMA : TokenType::T_COMMA)) { |
||
57 | $parser->match($shouldUseLexer ? Lexer::T_COMMA : TokenType::T_COMMA); |
||
58 | $parameter = $parser->Literal(); |
||
59 | $parameters[] = $parameter->value; |
||
60 | } |
||
61 | } |
||
62 | $parser->match($shouldUseLexer ? Lexer::T_CLOSE_PARENTHESIS : TokenType::T_CLOSE_PARENTHESIS); |
||
63 | $type .= '('.\implode(', ', $parameters).')'; |
||
64 | } |
||
65 | |||
66 | $this->targetType = $type; |
||
67 | |||
68 | $parser->match($shouldUseLexer ? Lexer::T_CLOSE_PARENTHESIS : TokenType::T_CLOSE_PARENTHESIS); |
||
69 | } |
||
76 |