| Conditions | 3 |
| Paths | 2 |
| Total Lines | 64 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 2 |
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 |
||
| 55 | protected function getArgvInputExtendedMockObject($withConfigFileOption, $withInstancesArguments = false, $dummyInstances = false) |
||
| 56 | { |
||
| 57 | $mockedMethods = ['isOptionSet', 'getOption', 'getArgument', 'hasArgument']; |
||
| 58 | $argvInputExtended = $this->getMock('Gerrie\Component\Console\ArgvInputExtended', $mockedMethods); |
||
| 59 | $argvInputExtended->expects($this->any()) |
||
| 60 | ->method('isOptionSet') |
||
| 61 | ->withConsecutive( |
||
| 62 | array($this->equalTo('config-file')), |
||
| 63 | array($this->equalTo('database-host')), |
||
| 64 | array($this->equalTo('database-user')), |
||
| 65 | array($this->equalTo('database-pass')), |
||
| 66 | array($this->equalTo('database-port')), |
||
| 67 | array($this->equalTo('database-name')) |
||
| 68 | ) |
||
| 69 | ->willReturnOnConsecutiveCalls( |
||
| 70 | $this->returnValue($withConfigFileOption), |
||
| 71 | $this->returnValue(true), |
||
| 72 | $this->returnValue(true), |
||
| 73 | $this->returnValue(false), |
||
| 74 | $this->returnValue(true), |
||
| 75 | $this->returnValue(false) |
||
| 76 | ); |
||
| 77 | |||
| 78 | $argvInputExtended->expects($this->any()) |
||
| 79 | ->method('getOption') |
||
| 80 | ->withConsecutive( |
||
| 81 | array($this->equalTo('database-host')), |
||
| 82 | array($this->equalTo('database-user')), |
||
| 83 | array($this->equalTo('database-port')) |
||
| 84 | ) |
||
| 85 | ->willReturnOnConsecutiveCalls( |
||
| 86 | $this->returnValue('HOST'), |
||
| 87 | $this->returnValue('USER'), |
||
| 88 | $this->returnValue('PORT') |
||
| 89 | ); |
||
| 90 | |||
| 91 | $argvInputExtended->expects($this->any()) |
||
| 92 | ->method('hasArgument') |
||
| 93 | ->with($this->equalTo('instances')) |
||
| 94 | ->will($this->returnValue($withInstancesArguments)); |
||
| 95 | |||
| 96 | if ($withInstancesArguments === true && $dummyInstances === true) { |
||
| 97 | $instances = $this->getDummyInstances(); |
||
| 98 | $argvInputExtended->expects($this->any()) |
||
| 99 | ->method('getArgument') |
||
| 100 | ->with($this->equalTo('instances')) |
||
| 101 | ->will($this->returnValue($instances)); |
||
| 102 | } |
||
| 103 | /* |
||
| 104 | if ($withInstancesArguments === false) { |
||
| 105 | |||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 | |||
| 110 | } else { |
||
| 111 | $argvInputExtended->expects($this->any()) |
||
| 112 | ->method('hasArgument') |
||
| 113 | ->with($this->equalTo('instances')) |
||
| 114 | ->will($this->returnValue(true)); |
||
| 115 | } |
||
| 116 | */ |
||
| 117 | return $argvInputExtended; |
||
| 118 | } |
||
| 119 | |||
| 185 | } |