| Conditions | 3 |
| Paths | 1 |
| Total Lines | 56 |
| Code Lines | 43 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 39 | public function testProcessWithTranslatable() |
||
| 40 | { |
||
| 41 | $container = $this->createContainerBuilderMock(); |
||
| 42 | $container |
||
| 43 | ->expects($this->once()) |
||
| 44 | ->method('findTaggedServiceIds') |
||
| 45 | ->with($this->identicalTo('lug.factory')) |
||
| 46 | ->will($this->returnValue([ |
||
| 47 | $factoryService = 'lug.factory.resource_name' => [['resource' => $resourceName = 'resource_name']], |
||
| 48 | ])); |
||
| 49 | |||
| 50 | $container |
||
| 51 | ->expects($this->exactly(3)) |
||
| 52 | ->method('getDefinition') |
||
| 53 | ->will($this->returnValueMap([ |
||
| 54 | [$factoryService, $factory = $this->createDefinitionMock()], |
||
| 55 | [$resourceService = 'lug.resource.resource_name', $resource = $this->createDefinitionMock()], |
||
| 56 | [$translationService = 'lug.resource.translation_name', $translation = $this->createDefinitionMock()], |
||
| 57 | ])); |
||
| 58 | |||
| 59 | $factory |
||
| 60 | ->expects($this->once()) |
||
| 61 | ->method('getClass') |
||
| 62 | ->will($this->returnValue(TranslatableFactory::class)); |
||
| 63 | |||
| 64 | $resource |
||
| 65 | ->expects($this->once()) |
||
| 66 | ->method('getMethodCalls') |
||
| 67 | ->will($this->returnValue([['addRelation', ['translation', $translationService]]])); |
||
| 68 | |||
| 69 | $translation |
||
| 70 | ->expects($this->once()) |
||
| 71 | ->method('getArgument') |
||
| 72 | ->with($this->identicalTo(0)) |
||
| 73 | ->will($this->returnValue($translationName = 'translation_name')); |
||
| 74 | |||
| 75 | $factory |
||
| 76 | ->expects($this->at(1)) |
||
| 77 | ->method('addArgument') |
||
| 78 | ->with($this->callback(function ($argument) { |
||
| 79 | return $argument instanceof Reference |
||
| 80 | && (string) $argument === 'lug.translation.context.locale'; |
||
| 81 | })) |
||
| 82 | ->will($this->returnSelf()); |
||
| 83 | |||
| 84 | $factory |
||
| 85 | ->expects($this->at(2)) |
||
| 86 | ->method('addArgument') |
||
| 87 | ->with($this->callback(function ($argument) use ($translationName) { |
||
| 88 | return $argument instanceof Reference |
||
| 89 | && (string) $argument === 'lug.factory.'.$translationName; |
||
| 90 | })) |
||
| 91 | ->will($this->returnSelf()); |
||
| 92 | |||
| 93 | $this->compiler->process($container); |
||
| 94 | } |
||
| 95 | |||
| 139 |