| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 16 | private function getMockAnnotatedConfig() |
||
| 17 | { |
||
| 18 | $config = $this->createMock('Doctrine\ORM\Configuration'); |
||
| 19 | $config |
||
| 20 | ->expects($this->once()) |
||
| 21 | ->method('getProxyDir') |
||
| 22 | ->will($this->returnValue(__DIR__ . '/temp')) |
||
| 23 | ; |
||
| 24 | |||
| 25 | $config |
||
| 26 | ->expects($this->once()) |
||
| 27 | ->method('getProxyNamespace') |
||
| 28 | ->will($this->returnValue('Proxy')) |
||
| 29 | ; |
||
| 30 | |||
| 31 | $config |
||
| 32 | ->expects($this->once()) |
||
| 33 | ->method('getAutoGenerateProxyClasses') |
||
| 34 | ->will($this->returnValue(true)) |
||
| 35 | ; |
||
| 36 | |||
| 37 | $config |
||
| 38 | ->expects($this->once()) |
||
| 39 | ->method('getClassMetadataFactoryName') |
||
| 40 | ->will($this->returnValue('Doctrine\\ORM\\Mapping\\ClassMetadataFactory')) |
||
| 41 | ; |
||
| 42 | |||
| 43 | $mappingDriver = $this->getMetadataDriverImplementation(); |
||
| 44 | |||
| 45 | $config |
||
| 46 | ->expects($this->any()) |
||
| 47 | ->method('getMetadataDriverImpl') |
||
| 48 | ->will($this->returnValue($mappingDriver)) |
||
| 49 | ; |
||
| 50 | |||
| 51 | $config |
||
| 52 | ->expects($this->any()) |
||
| 53 | ->method('getDefaultRepositoryClassName') |
||
| 54 | ->will($this->returnValue('Doctrine\\ORM\\EntityRepository')) |
||
| 55 | ; |
||
| 56 | |||
| 57 | $quoteStrategy = new DefaultQuoteStrategy(); |
||
| 58 | |||
| 59 | $config |
||
| 60 | ->expects($this->any()) |
||
| 61 | ->method('getQuoteStrategy') |
||
| 62 | ->will($this->returnValue($quoteStrategy)) |
||
| 63 | ; |
||
| 64 | |||
| 65 | $repositoryFactory = new DefaultRepositoryFactory(); |
||
| 66 | |||
| 67 | $config |
||
| 68 | ->expects($this->any()) |
||
| 69 | ->method('getRepositoryFactory') |
||
| 70 | ->will($this->returnValue($repositoryFactory)) |
||
| 71 | ; |
||
| 72 | |||
| 73 | return $config; |
||
| 74 | } |
||
| 75 | |||
| 132 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: