Conditions | 17 |
Paths | 17 |
Total Lines | 29 |
Code Lines | 22 |
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 |
||
51 | protected function parseDefinition(LexerInterface $lexer): array |
||
52 | { |
||
53 | if ($this->peek($lexer, TokenKindEnum::NAME)) { |
||
54 | switch ($lexer->getTokenValue()) { |
||
55 | case KeywordEnum::QUERY: |
||
56 | case KeywordEnum::MUTATION: |
||
57 | case KeywordEnum::SUBSCRIPTION: |
||
58 | case KeywordEnum::FRAGMENT: |
||
59 | return $this->buildAST(ASTKindEnum::EXECUTABLE_DEFINITION, $lexer); |
||
|
|||
60 | case KeywordEnum::SCHEMA: |
||
61 | case KeywordEnum::SCALAR: |
||
62 | case KeywordEnum::TYPE: |
||
63 | case KeywordEnum::INTERFACE: |
||
64 | case KeywordEnum::UNION: |
||
65 | case KeywordEnum::ENUM: |
||
66 | case KeywordEnum::INPUT: |
||
67 | case KeywordEnum::EXTEND: |
||
68 | case KeywordEnum::DIRECTIVE: |
||
69 | // Note: The schema definition language is an experimental addition. |
||
70 | return $this->buildAST(ASTKindEnum::TYPE_SYSTEM_DEFINITION, $lexer); |
||
71 | } |
||
72 | } elseif ($this->peek($lexer, TokenKindEnum::BRACE_L)) { |
||
73 | return $this->buildAST(ASTKindEnum::EXECUTABLE_DEFINITION, $lexer); |
||
74 | } elseif ($this->peekDescription($lexer)) { |
||
75 | // Note: The schema definition language is an experimental addition. |
||
76 | return $this->buildAST(ASTKindEnum::TYPE_SYSTEM_DEFINITION, $lexer); |
||
77 | } |
||
78 | |||
79 | throw $this->unexpected($lexer); |
||
80 | } |
||
82 |