Conditions | 4 |
Paths | 8 |
Total Lines | 59 |
Lines | 38 |
Ratio | 64.41 % |
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 |
||
85 | private function getMockExpression(bool $includeLinkJoin, bool $includeAttributeJoin, bool $includeTreeJoin) |
||
86 | { |
||
87 | $execAt = 0; |
||
88 | $expr = $this->createMock(Expression::class); |
||
89 | if ($includeLinkJoin) { |
||
90 | $expr |
||
91 | ->expects($this->at($execAt++)) |
||
92 | ->method('eq') |
||
93 | ->with('ezurl.id', 'ezurl_object_link.url_id') |
||
94 | ->willReturn('ezurl.id=ezurl_object_link.url_id'); |
||
95 | } |
||
96 | View Code Duplication | if ($includeAttributeJoin) { |
|
97 | $expr |
||
98 | ->expects($this->at($execAt++)) |
||
99 | ->method('eq') |
||
100 | ->with('ezurl_object_link.contentobject_attribute_id', 'ezcontentobject_attribute.id') |
||
101 | ->willReturn('ezurl_object_link.contentobject_attribute_id = ezcontentobject_attribute.id'); |
||
102 | $expr |
||
103 | ->expects($this->at($execAt++)) |
||
104 | ->method('eq') |
||
105 | ->with('ezurl_object_link.contentobject_attribute_version', 'ezcontentobject_attribute.version') |
||
106 | ->willReturn('ezurl_object_link.contentobject_attribute_version = ezcontentobject_attribute.version'); |
||
107 | $expr |
||
108 | ->expects($this->at($execAt++)) |
||
109 | ->method('lAnd') |
||
110 | ->with( |
||
111 | 'ezurl_object_link.contentobject_attribute_id = ezcontentobject_attribute.id', |
||
112 | 'ezurl_object_link.contentobject_attribute_version = ezcontentobject_attribute.version' |
||
113 | )->willReturn('ezurl_object_link.contentobject_attribute_id = ezcontentobject_attribute.id AND ezurl_object_link.contentobject_attribute_version = ezcontentobject_attribute.version'); |
||
114 | } |
||
115 | |||
116 | View Code Duplication | if ($includeTreeJoin) { |
|
117 | $expr |
||
118 | ->expects($this->at($execAt++)) |
||
119 | ->method('eq') |
||
120 | ->with('ezcontentobject_tree.contentobject_id', 'ezcontentobject_attribute.contentobject_id') |
||
121 | ->willReturn('ezcontentobject_tree.contentobject_id = ezcontentobject_attribute.contentobject_id'); |
||
122 | $expr |
||
123 | ->expects($this->at($execAt++)) |
||
124 | ->method('eq') |
||
125 | ->with('ezcontentobject_tree.contentobject_version', 'ezcontentobject_attribute.version') |
||
126 | ->willReturn('ezcontentobject_tree.contentobject_version = ezcontentobject_attribute.version'); |
||
127 | $expr |
||
128 | ->expects($this->at($execAt++)) |
||
129 | ->method('lAnd') |
||
130 | ->with( |
||
131 | 'ezcontentobject_tree.contentobject_id = ezcontentobject_attribute.contentobject_id', |
||
132 | 'ezcontentobject_tree.contentobject_version = ezcontentobject_attribute.version' |
||
133 | )->willReturn('ezcontentobject_tree.contentobject_id = ezcontentobject_attribute.contentobject_id AND ezcontentobject_tree.contentobject_version = ezcontentobject_attribute.version'); |
||
134 | } |
||
135 | |||
136 | $expr |
||
137 | ->expects($this->at($execAt)) |
||
138 | ->method('eq') |
||
139 | ->with('ezcontentobject_tree.is_invisible', '0') |
||
140 | ->willReturn('ezcontentobject_tree.is_invisible = 0'); |
||
141 | |||
142 | return $expr; |
||
143 | } |
||
144 | } |
||
145 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.