Conditions | 11 |
Paths | 7 |
Total Lines | 33 |
Code Lines | 23 |
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 |
||
43 | public function analyzing(Router $router, string $contracts, string $implementer) : void |
||
44 | { |
||
45 | if (is_file($f = $this->file($implementer))) { |
||
46 | $tree = parse_file($f, $ver = 50); |
||
47 | if ($tree->kind === AST_STMT_LIST) { |
||
48 | $uses = []; |
||
49 | /** |
||
50 | * @var Node $stmt |
||
51 | * @var Node $use |
||
52 | */ |
||
53 | foreach ($tree->children as $stmt) { |
||
54 | switch ($stmt->kind) { |
||
55 | case AST_USE: |
||
56 | $ifo = $stmt->children[0]->children; |
||
57 | $uses[$ifo['alias'] ?? array_slice(explode('\\', $ifo['name']), -1)[0]] = $ifo['name']; |
||
58 | break; |
||
59 | case AST_CLASS: |
||
60 | $imps = $stmt->children['implements'] ?? null; |
||
61 | if ($imps instanceof Node && $imps->kind === AST_NAME_LIST) { |
||
62 | foreach ($imps->children as $use) { |
||
63 | $use->kind === AST_NAME && $this->assigning( |
||
64 | $router, |
||
65 | $contracts, |
||
66 | array_slice(explode( |
||
67 | '\\', |
||
68 | $use->flags === USE_NORMAL |
||
69 | ? ($uses[$use->children['name']] ?? '') |
||
70 | : $use->children['name'] |
||
71 | ), 0, -1) |
||
72 | ); |
||
73 | } |
||
74 | } |
||
75 | break; |
||
76 | } |
||
134 |