| Conditions | 4 |
| Paths | 3 |
| Total Lines | 82 |
| Code Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 154 | protected function getMockAnnotatedConfig() |
||
| 155 | { |
||
| 156 | // We need to mock every method except the ones which |
||
| 157 | // handle the filters |
||
| 158 | $configurationClass = 'Doctrine\ORM\Configuration'; |
||
| 159 | $refl = new \ReflectionClass($configurationClass); |
||
| 160 | $methods = $refl->getMethods(); |
||
| 161 | |||
| 162 | $mockMethods = array(); |
||
| 163 | |||
| 164 | foreach ($methods as $method) { |
||
| 165 | if ($method->name !== 'addFilter' && $method->name !== 'getFilterClassName') { |
||
| 166 | $mockMethods[] = $method->name; |
||
| 167 | } |
||
| 168 | } |
||
| 169 | |||
| 170 | $config = $this->getMock($configurationClass, $mockMethods); |
||
| 171 | |||
| 172 | $config |
||
| 173 | ->expects($this->once()) |
||
| 174 | ->method('getProxyDir') |
||
| 175 | ->will($this->returnValue(__DIR__.'/../temp')) |
||
| 176 | ; |
||
| 177 | |||
| 178 | $config |
||
| 179 | ->expects($this->once()) |
||
| 180 | ->method('getProxyNamespace') |
||
| 181 | ->will($this->returnValue('Proxy')) |
||
| 182 | ; |
||
| 183 | |||
| 184 | $config |
||
| 185 | ->expects($this->any()) |
||
| 186 | ->method('getDefaultQueryHints') |
||
| 187 | ->will($this->returnValue(array())) |
||
| 188 | ; |
||
| 189 | |||
| 190 | $config |
||
| 191 | ->expects($this->once()) |
||
| 192 | ->method('getAutoGenerateProxyClasses') |
||
| 193 | ->will($this->returnValue(true)) |
||
| 194 | ; |
||
| 195 | |||
| 196 | $config |
||
| 197 | ->expects($this->once()) |
||
| 198 | ->method('getClassMetadataFactoryName') |
||
| 199 | ->will($this->returnValue('Doctrine\\ORM\\Mapping\\ClassMetadataFactory')) |
||
| 200 | ; |
||
| 201 | |||
| 202 | $mappingDriver = $this->getMetadataDriverImplementation(); |
||
| 203 | |||
| 204 | $config |
||
| 205 | ->expects($this->any()) |
||
| 206 | ->method('getMetadataDriverImpl') |
||
| 207 | ->will($this->returnValue($mappingDriver)) |
||
| 208 | ; |
||
| 209 | |||
| 210 | $config |
||
| 211 | ->expects($this->any()) |
||
| 212 | ->method('getDefaultRepositoryClassName') |
||
| 213 | ->will($this->returnValue('Doctrine\\ORM\\EntityRepository')) |
||
| 214 | ; |
||
| 215 | |||
| 216 | $config |
||
| 217 | ->expects($this->any()) |
||
| 218 | ->method('getQuoteStrategy') |
||
| 219 | ->will($this->returnValue(new DefaultQuoteStrategy())) |
||
| 220 | ; |
||
| 221 | |||
| 222 | $config |
||
| 223 | ->expects($this->any()) |
||
| 224 | ->method('getNamingStrategy') |
||
| 225 | ->will($this->returnValue(new DefaultNamingStrategy())) |
||
| 226 | ; |
||
| 227 | |||
| 228 | $config |
||
| 229 | ->expects($this->once()) |
||
| 230 | ->method('getRepositoryFactory') |
||
| 231 | ->will($this->returnValue(new DefaultRepositoryFactory())) |
||
| 232 | ; |
||
| 233 | |||
| 234 | return $config; |
||
| 235 | } |
||
| 236 | |||
| 250 |