| Conditions | 2 |
| Paths | 2 |
| Total Lines | 73 |
| Code Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | 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 |
||
| 53 | public function testIfCorrectFilesAreBeingYielded() |
||
| 54 | { |
||
| 55 | $isHidden = m::mock('Flyfinder\Specification\IsHidden'); |
||
| 56 | $filesystem = m::mock('League\Flysystem\Filesystem'); |
||
| 57 | |||
| 58 | $listContents1 = [ |
||
| 59 | 0 => [ |
||
| 60 | 'type' => 'dir', |
||
| 61 | 'path' => '.hiddendir', |
||
| 62 | 'dirname' => '', |
||
| 63 | 'basename' => '.hiddendir', |
||
| 64 | 'filename' => '.hiddendir', |
||
| 65 | ], |
||
| 66 | 1 => [ |
||
| 67 | 'type' => 'file', |
||
| 68 | 'path' => 'test.txt', |
||
| 69 | 'basename' => 'test.txt', |
||
| 70 | ], |
||
| 71 | ]; |
||
| 72 | |||
| 73 | $listContents2 = [ |
||
| 74 | 0 => [ |
||
| 75 | 'type' => 'file', |
||
| 76 | 'path' => '.hiddendir/.test.txt', |
||
| 77 | 'dirname' => '.hiddendir', |
||
| 78 | 'basename' => '.test.txt', |
||
| 79 | 'filename' => '.test', |
||
| 80 | 'extension' => 'txt', |
||
| 81 | ], |
||
| 82 | ]; |
||
| 83 | |||
| 84 | $filesystem->shouldReceive('listContents') |
||
| 85 | ->with('') |
||
| 86 | ->andReturn($listContents1); |
||
| 87 | |||
| 88 | $filesystem->shouldReceive('listContents') |
||
| 89 | ->with('.hiddendir') |
||
| 90 | ->andReturn($listContents2); |
||
| 91 | |||
| 92 | $isHidden->shouldReceive('isSatisfiedBy') |
||
| 93 | ->with($listContents1[0]) |
||
| 94 | ->andReturn(true); |
||
| 95 | |||
| 96 | $isHidden->shouldReceive('isSatisfiedBy') |
||
| 97 | ->with($listContents1[1]) |
||
| 98 | ->andReturn(false); |
||
| 99 | |||
| 100 | $isHidden->shouldReceive('isSatisfiedBy') |
||
| 101 | ->with($listContents2[0]) |
||
| 102 | ->andReturn(true); |
||
| 103 | |||
| 104 | $this->fixture->setFilesystem($filesystem); |
||
| 105 | $generator = $this->fixture->handle($isHidden); |
||
| 106 | |||
| 107 | $result = []; |
||
| 108 | |||
| 109 | foreach ($generator as $value) { |
||
| 110 | $result[] = $value; |
||
| 111 | } |
||
| 112 | |||
| 113 | $expected = [ |
||
| 114 | 0 => [ |
||
| 115 | 'type' => 'file', |
||
| 116 | 'path' => '.hiddendir/.test.txt', |
||
| 117 | 'dirname' => '.hiddendir', |
||
| 118 | 'basename' => '.test.txt', |
||
| 119 | 'filename' => '.test', |
||
| 120 | 'extension' => 'txt', |
||
| 121 | ], |
||
| 122 | ]; |
||
| 123 | |||
| 124 | $this->assertSame($expected, $result); |
||
| 125 | } |
||
| 126 | } |
||
| 127 |