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