| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 52 | 
| Lines | 0 | 
| Ratio | 0 % | 
| 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 | ||
| 100 | public function testWillTryAutoGeneration() : void | ||
| 101 |     { | ||
| 102 | $instance = new stdClass(); | ||
| 103 |         $proxyClassName = UniqueIdentifierGenerator::getIdentifier('bar'); | ||
| 104 | $generator = $this->createMock(GeneratorStrategyInterface::class); | ||
| 105 | $autoloader = $this->createMock(AutoloaderInterface::class); | ||
| 106 | |||
| 107 |         $this->config->method('getGeneratorStrategy')->will(self::returnValue($generator)); | ||
| 108 |         $this->config->method('getProxyAutoloader')->will(self::returnValue($autoloader)); | ||
| 109 | |||
| 110 | $generator | ||
| 111 | ->expects(self::once()) | ||
| 112 |             ->method('generate') | ||
| 113 | ->with( | ||
| 114 | self::callback( | ||
| 115 |                     static function (ClassGenerator $targetClass) use ($proxyClassName) : bool { | ||
| 116 | return $targetClass->getName() === $proxyClassName; | ||
| 117 | } | ||
| 118 | ) | ||
| 119 | ); | ||
| 120 | |||
| 121 | // simulate autoloading | ||
| 122 | $autoloader | ||
| 123 | ->expects(self::once()) | ||
| 124 |             ->method('__invoke') | ||
| 125 | ->with($proxyClassName) | ||
| 126 |             ->willReturnCallback(static function () use ($proxyClassName) : bool { | ||
| 127 |                 eval('class ' . $proxyClassName . ' extends \\ProxyManagerTestAsset\\NullObjectMock {}'); | ||
| 128 | |||
| 129 | return true; | ||
| 130 | }); | ||
| 131 | |||
| 132 | $this | ||
| 133 | ->inflector | ||
| 134 | ->expects(self::once()) | ||
| 135 |             ->method('getProxyClassName') | ||
| 136 |             ->with('stdClass') | ||
| 137 | ->willReturn($proxyClassName); | ||
| 138 | |||
| 139 | $this | ||
| 140 | ->inflector | ||
| 141 | ->expects(self::once()) | ||
| 142 |             ->method('getUserClassName') | ||
| 143 |             ->with('stdClass') | ||
| 144 | ->willReturn(NullObjectMock::class); | ||
| 145 | |||
| 146 |         $this->signatureChecker->expects(self::atLeastOnce())->method('checkSignature'); | ||
| 147 |         $this->classSignatureGenerator->expects(self::once())->method('addSignature')->will(self::returnArgument(0)); | ||
| 148 | |||
| 149 | $factory = new NullObjectFactory($this->config); | ||
| 150 | $factory->createProxy($instance); | ||
| 151 | } | ||
| 152 | } | ||
| 153 |