| Conditions | 1 |
| Paths | 1 |
| Total Lines | 56 |
| 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 |
||
| 92 | public function testCopyRecursiveWithExcludedFile() |
||
| 93 | { |
||
| 94 | $this->fixtures->createAndCdToSandbox(); |
||
| 95 | |||
| 96 | $this->assertFileExists('some/deeply/nested'); |
||
| 97 | $this->assertFileExists('some/deeply/nested2'); |
||
| 98 | $this->assertFileExists('some/deeply/nested3'); |
||
| 99 | $this->assertFileExists('some/deeply/nested3/nested31'); |
||
| 100 | $this->assertFileExists('some/deeply/nested4'); |
||
| 101 | $this->assertFileExists('some/deeply/nested4/nested41'); |
||
| 102 | $this->assertFileExists('some/deeply/nested/structu.re'); |
||
| 103 | $this->assertFileExists('some/deeply/nested/structu1.re'); |
||
| 104 | $this->assertFileExists('some/deeply/nested/structu2.re'); |
||
| 105 | $this->assertFileExists('some/deeply/nested/structu3.re'); |
||
| 106 | $this->assertFileExists('some/deeply/nested2/structu21.re'); |
||
| 107 | $this->assertFileExists('some/deeply/nested3/structu31.re'); |
||
| 108 | $this->assertFileExists('some/deeply/nested3/structu32.re'); |
||
| 109 | $this->assertFileExists('some/deeply/nested3/nested31/structu311.re'); |
||
| 110 | $this->assertFileExists('some/deeply/nested4/nested41/structu411.re'); |
||
| 111 | $this->assertFileExists('some/deeply/nested4/nested41/structu412.re'); |
||
| 112 | |||
| 113 | $result = $this->taskCopyDir(['some/deeply' => 'some_destination/deeply']) |
||
| 114 | ->exclude([ |
||
| 115 | // Basename exclusion. |
||
| 116 | 'structu1.re', |
||
| 117 | // File in subdir exclusion. |
||
| 118 | 'some/deeply/nested/structu3.re', |
||
| 119 | // Dir exclusion. |
||
| 120 | 'nested2', |
||
| 121 | // Subdir exclusion. |
||
| 122 | 'some/deeply/nested3/nested31', |
||
| 123 | // Subpath within source exclusion. |
||
| 124 | 'nested3/structu31.re', |
||
| 125 | // File in deeper subpath within source exclusion. |
||
| 126 | 'nested4/nested41/structu411.re', |
||
| 127 | ]) |
||
| 128 | ->run(); |
||
| 129 | $this->assertTrue($result->wasSuccessful()); |
||
| 130 | |||
| 131 | $this->assertFileExists('some_destination/deeply/nested'); |
||
| 132 | $this->assertFileNotExists('some_destination/deeply/nested2'); |
||
| 133 | $this->assertFileExists('some_destination/deeply/nested3'); |
||
| 134 | $this->assertFileNotExists('some_destination/deeply/nested3/nested31'); |
||
| 135 | $this->assertFileExists('some_destination/deeply/nested4'); |
||
| 136 | $this->assertFileExists('some_destination/deeply/nested4/nested41'); |
||
| 137 | $this->assertFileExists('some_destination/deeply/nested/structu.re'); |
||
| 138 | $this->assertFileNotExists('some_destination/deeply/nested/structu1.re'); |
||
| 139 | $this->assertFileExists('some_destination/deeply/nested/structu2.re'); |
||
| 140 | $this->assertFileNotExists('some_destination/deeply/nested/structu3.re'); |
||
| 141 | $this->assertFileNotExists('some_destination/deeply/nested2/structu21.re'); |
||
| 142 | $this->assertFileNotExists('some_destination/deeply/nested3/structu31.re'); |
||
| 143 | $this->assertFileExists('some_destination/deeply/nested3/structu32.re'); |
||
| 144 | $this->assertFileNotExists('some_destination/deeply/nested3/nested31/structu311.re'); |
||
| 145 | $this->assertFileNotExists('some_destination/deeply/nested4/nested41/structu411.re'); |
||
| 146 | $this->assertFileExists('some_destination/deeply/nested4/nested41/structu412.re'); |
||
| 147 | } |
||
| 148 | } |
||
| 149 |
If you suppress an error, we recommend checking for the error condition explicitly: