Conditions | 20 |
Paths | 3456 |
Total Lines | 100 |
Code Lines | 43 |
Lines | 0 |
Ratio | 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 |
||
76 | function testNotifications() { |
||
77 | // {{{ Listener cannot read moved item |
||
78 | // We expect no notification |
||
79 | $dr = 0; |
||
80 | for($br = 0 ; $br <= 1 ; ++$br) { |
||
81 | for($cr = 0 ; $cr <= 1 ; ++$cr) { |
||
82 | for ($lb = 0 ; $lb <= 1 ; ++$lb) { |
||
83 | for ($lc = 0 ; $lc <= 1 ; ++$lc) { |
||
84 | for ($ld = 0 ; $ld <= 1 ; ++$ld) { |
||
85 | $this->_runTest($dr, $br, $cr, $lb, $lc, $ld, 'none'); |
||
86 | } |
||
87 | } |
||
88 | } |
||
89 | } |
||
90 | } |
||
91 | //}}} |
||
92 | // {{{ Listener can read moved item |
||
93 | $dr = 1; |
||
94 | // {{{ Listener cannot read old parent |
||
95 | $br = 0; |
||
96 | // {{{ Listener cannot read new parent |
||
97 | // We expect no notification |
||
98 | $cr = 0; |
||
99 | for ($lb = 0 ; $lb <= 1 ; ++$lb) { |
||
100 | for ($lc = 0 ; $lc <= 1 ; ++$lc) { |
||
101 | for ($ld = 0 ; $ld <= 1 ; ++$ld) { |
||
102 | $this->_runTest($dr, $br, $cr, $lb, $lc, $ld, 'none'); |
||
103 | } |
||
104 | } |
||
105 | } |
||
106 | //}}} |
||
107 | // {{{ Listener can read new parent |
||
108 | // => A readable item is moved from an unreadable parent to a readable one |
||
109 | $cr = 1; |
||
110 | //{{{ Do not listen item but maybe its parent ? |
||
111 | $ld = 0; |
||
112 | // No listeners, no notification |
||
113 | $this->_runTest($dr, $br, $cr, 0, 0, $ld, 'none'); |
||
114 | // Only old parent is listened (but still unreadable), no notification |
||
115 | $this->_runTest($dr, $br, $cr, 1, 0, $ld, 'none'); |
||
116 | // {{{ new parent is listened, we receive a notification without b because it is still unreadable |
||
117 | for ($lb = 0 ; $lb <= 1 ; ++$lb) { |
||
118 | $this->_runTest($dr, $br, $cr, $lb, 1, $ld, 'to_wo_b'); |
||
119 | } |
||
120 | //}}} |
||
121 | //}}} |
||
122 | |||
123 | //{{{ If we listen item, we receive a notification about item ("has been moved to c") |
||
124 | $ld = 1; |
||
125 | for ($lb = 0 ; $lb <= 1 ; ++$lb) { |
||
126 | for ($lc = 0 ; $lc <= 1 ; ++$lc) { |
||
127 | $this->_runTest($dr, $br, $cr, $lb, $lc, $ld, 'item'); |
||
128 | } |
||
129 | } |
||
130 | //}}} |
||
131 | //}}} |
||
132 | //}}} |
||
133 | // {{{ Listener can read old parent |
||
134 | $br = 1; |
||
135 | // {{{ Listener cannot read new parent |
||
136 | // We have to send notifications only when old parent or item is listened |
||
137 | $cr = 0; |
||
138 | for ($lb = 0 ; $lb <= 1 ; ++$lb) { |
||
139 | for ($lc = 0 ; $lc <= 1 ; ++$lc) { |
||
140 | for ($ld = 0 ; $ld <= 1 ; ++$ld) { |
||
141 | $this->_runTest($dr, $br, $cr, $lb, $lc, $ld, $lb || $ld ? 'from_wo_c' : 'none'); |
||
142 | } |
||
143 | } |
||
144 | } |
||
145 | //}}} |
||
146 | // {{{ Listener can read new parent |
||
147 | $cr = 1; |
||
148 | // {{{ Moved item is listened, notification on item |
||
149 | $ld = 1; |
||
150 | for ($lb = 0 ; $lb <= 1 ; ++$lb) { |
||
151 | for ($lc = 0 ; $lc <= 1 ; ++$lc) { |
||
152 | $this->_runTest($dr, $br, $cr, $lb, $lc, $ld, 'item'); |
||
153 | } |
||
154 | } |
||
155 | //}}} |
||
156 | //{{{ Moved item is not listened |
||
157 | $ld = 0; |
||
158 | // {{{ new parent is listened, notification 'to' |
||
159 | $lc = 1; |
||
160 | for ($lb = 0 ; $lb <= 1 ; ++$lb) { |
||
161 | $this->_runTest($dr, $br, $cr, $lb, $lc, $ld, 'to'); |
||
162 | } |
||
163 | //}}} |
||
164 | // {{{ new parent is not listened |
||
165 | $lc = 0; |
||
166 | //Old parent is listened, 'from' notification |
||
167 | $this->_runTest($dr, $br, $cr, 1, $lc, $ld, 'from'); |
||
168 | //No listener, no notification |
||
169 | $this->_runTest($dr, $br, $cr, 0, $lc, $ld, 'none'); |
||
170 | //}}} |
||
171 | //}}} |
||
172 | //}}} |
||
173 | //}}} |
||
174 | //}}} |
||
175 | } |
||
176 | /** |
||
303 |