Conditions | 1 |
Paths | 1 |
Total Lines | 78 |
Code Lines | 63 |
Lines | 0 |
Ratio | 0 % |
Changes | 7 | ||
Bugs | 1 | Features | 5 |
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 |
||
58 | public function __construct() |
||
59 | { |
||
60 | $this->add( |
||
61 | Path::factory( |
||
62 | '/dependency-injection/class-definition', |
||
63 | 'classDefs', |
||
64 | array() |
||
65 | )->loop(true, '@name') |
||
66 | ->attribute('shared') |
||
67 | ->attribute('lazy') |
||
68 | ->attribute('class', 'className') |
||
69 | ->addChildren( |
||
70 | Path::factory('argument', 'arguments', array()) |
||
71 | ->loop(true) |
||
72 | ->value('value') |
||
73 | )->addChildren( |
||
74 | Path::factory('call', 'methodsCalls', array()) |
||
75 | ->loop(true) |
||
76 | ->attribute('method') |
||
77 | ->addChildren( |
||
78 | Path::factory('argument', 'arguments', array()) |
||
79 | ->loop(true) |
||
80 | ->value('value') |
||
81 | ) |
||
82 | )->addChildren( |
||
83 | Path::factory('data/param', 'data', array()) |
||
84 | ->loop(true, '@key') |
||
85 | ->value('value') |
||
86 | ) |
||
87 | ); |
||
88 | |||
89 | $this->add( |
||
90 | Path::factory( |
||
91 | '/dependency-injection/definition', |
||
92 | 'definitions', |
||
93 | array() |
||
94 | )->loop(true, '@name') |
||
95 | ->attribute('shared') |
||
96 | ->value('value') |
||
97 | ); |
||
98 | |||
99 | $this->add( |
||
100 | Path::factory('/dependency-injection/ini', 'ini', array()) |
||
101 | ->loop(true) |
||
102 | ->attribute('category') |
||
103 | ->value('value') |
||
104 | ); |
||
105 | |||
106 | $this->add( |
||
107 | Path::factory( |
||
108 | '/dependency-injection/array-definition', |
||
109 | 'arrayDefs', |
||
110 | array() |
||
111 | )->loop(true, '@name') |
||
112 | ->attribute('shared') |
||
113 | ->addChildren( |
||
114 | Path::factory('param', 'params', array()) |
||
115 | ->loop(true) |
||
116 | ->attribute('key') |
||
117 | ->value('value') |
||
118 | ) |
||
119 | ->addChildren( |
||
120 | Path::factory('data/param', 'data', array()) |
||
121 | ->loop(true, '@key') |
||
122 | ->value('value') |
||
123 | ) |
||
124 | ); |
||
125 | |||
126 | $this->add( |
||
127 | Path::factory( |
||
128 | '/dependency-injection/listener', |
||
129 | 'listeners', |
||
130 | array() |
||
131 | )->loop(true) |
||
132 | ->attribute('class') |
||
133 | ->attribute('service') |
||
134 | ); |
||
135 | } |
||
136 | } |