Conditions | 1 |
Paths | 1 |
Total Lines | 145 |
Code Lines | 103 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
25 | public function providePatchTermList() { |
||
26 | return array( |
||
27 | 'add a term' => array( |
||
28 | new TermList(), |
||
29 | new Diff( array( |
||
30 | 'en' => new DiffOpAdd( 'foo' ) |
||
31 | ) ), |
||
32 | new TermList( array( |
||
33 | new Term( 'en', 'foo' ) |
||
34 | ) ) |
||
35 | ), |
||
36 | 'change a term' => array( |
||
37 | new TermList( array( |
||
38 | new Term( 'en', 'foo' ) |
||
39 | ) ), |
||
40 | new Diff( array( |
||
41 | 'en' => new DiffOpChange( 'foo', 'bar' ) |
||
42 | ) ), |
||
43 | new TermList( array( |
||
44 | new Term( 'en', 'bar' ) |
||
45 | ) ) |
||
46 | ), |
||
47 | 'remove a term' => array( |
||
48 | new TermList( array( |
||
49 | new Term( 'en', 'foo' ) |
||
50 | ) ), |
||
51 | new Diff( array( |
||
52 | 'en' => new DiffOpRemove( 'foo' ) |
||
53 | ) ), |
||
54 | new TermList() |
||
55 | ), |
||
56 | 'add an existing language is no-op' => array( |
||
57 | new TermList( array( |
||
58 | new Term( 'en', 'foo' ) |
||
59 | ) ), |
||
60 | new Diff( array( |
||
61 | 'en' => new DiffOpAdd( 'bar' ) |
||
62 | ) ), |
||
63 | new TermList( array( |
||
64 | new Term( 'en', 'foo' ) |
||
65 | ) ) |
||
66 | ), |
||
67 | 'add two terms' => array( |
||
68 | new TermList( array( |
||
69 | new Term( 'en', 'foo' ) |
||
70 | ) ), |
||
71 | new Diff( array( |
||
72 | 'de' => new DiffOpAdd( 'bar' ), |
||
73 | 'nl' => new DiffOpAdd( 'baz' ) |
||
74 | ) ), |
||
75 | new TermList( array( |
||
76 | new Term( 'en', 'foo' ), |
||
77 | new Term( 'de', 'bar' ), |
||
78 | new Term( 'nl', 'baz' ) |
||
79 | ) ) |
||
80 | ), |
||
81 | 'remove a not existing language is no-op' => array( |
||
82 | new TermList( array( |
||
83 | new Term( 'en', 'foo' ) |
||
84 | ) ), |
||
85 | new Diff( array( |
||
86 | 'de' => new DiffOpRemove( 'bar' ) |
||
87 | ) ), |
||
88 | new TermList( array( |
||
89 | new Term( 'en', 'foo' ) |
||
90 | ) ) |
||
91 | ), |
||
92 | 'change a different value is no-op' => array( |
||
93 | new TermList( array( |
||
94 | new Term( 'en', 'foo' ) |
||
95 | ) ), |
||
96 | new Diff( array( |
||
97 | 'en' => new DiffOpChange( 'bar', 'baz' ) |
||
98 | ) ), |
||
99 | new TermList( array( |
||
100 | new Term( 'en', 'foo' ) |
||
101 | ) ) |
||
102 | ), |
||
103 | 'remove a different value is no-op' => array( |
||
104 | new TermList( array( |
||
105 | new Term( 'en', 'foo' ) |
||
106 | ) ), |
||
107 | new Diff( array( |
||
108 | 'en' => new DiffOpRemove( 'bar' ) |
||
109 | ) ), |
||
110 | new TermList( array( |
||
111 | new Term( 'en', 'foo' ) |
||
112 | ) ) |
||
113 | ), |
||
114 | 'complex diff (associative)' => array( |
||
115 | new TermList( array( |
||
116 | new Term( 'en', 'foo' ), |
||
117 | new Term( 'de', 'bar' ), |
||
118 | new Term( 'nl', 'baz' ) |
||
119 | ) ), |
||
120 | new Diff( array( |
||
121 | 'en' => new DiffOpChange( 'foo', 'bar' ), |
||
122 | 'de' => new DiffOpRemove( 'bar' ), |
||
123 | 'nl' => new DiffOpChange( 'bar', 'foo' ), |
||
124 | 'it' => new DiffOpAdd( 'foo' ) |
||
125 | ), true ), |
||
126 | new TermList( array( |
||
127 | new Term( 'en', 'bar' ), |
||
128 | new Term( 'nl', 'baz' ), |
||
129 | new Term( 'it', 'foo' ) |
||
130 | ) ) |
||
131 | ), |
||
132 | 'complex diff (non-associative)' => array( |
||
133 | new TermList( array( |
||
134 | new Term( 'en', 'foo' ), |
||
135 | new Term( 'de', 'bar' ), |
||
136 | new Term( 'nl', 'baz' ) |
||
137 | ) ), |
||
138 | new Diff( array( |
||
139 | 'en' => new DiffOpChange( 'foo', 'bar' ), |
||
140 | 'de' => new DiffOpRemove( 'bar' ), |
||
141 | 'nl' => new DiffOpChange( 'bar', 'foo' ), |
||
142 | 'it' => new DiffOpAdd( 'foo' ) |
||
143 | ), false ), |
||
144 | new TermList( array( |
||
145 | new Term( 'en', 'bar' ), |
||
146 | new Term( 'nl', 'baz' ), |
||
147 | new Term( 'it', 'foo' ) |
||
148 | ) ) |
||
149 | ), |
||
150 | 'complex diff (auto-detected)' => array( |
||
151 | new TermList( array( |
||
152 | new Term( 'en', 'foo' ), |
||
153 | new Term( 'de', 'bar' ), |
||
154 | new Term( 'nl', 'baz' ) |
||
155 | ) ), |
||
156 | new Diff( array( |
||
157 | 'en' => new DiffOpChange( 'foo', 'bar' ), |
||
158 | 'de' => new DiffOpRemove( 'bar' ), |
||
159 | 'nl' => new DiffOpChange( 'bar', 'foo' ), |
||
160 | 'it' => new DiffOpAdd( 'foo' ) |
||
161 | ) ), |
||
162 | new TermList( array( |
||
163 | new Term( 'en', 'bar' ), |
||
164 | new Term( 'nl', 'baz' ), |
||
165 | new Term( 'it', 'foo' ) |
||
166 | ) ) |
||
167 | ), |
||
168 | ); |
||
169 | } |
||
170 | |||
182 |