| Conditions | 4 |
| Paths | 4 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | 21 | public function handle($dirname, $options) |
|
| 30 | { |
||
| 31 | 21 | $dirname = Util::normalizePath($dirname); |
|
| 32 | |||
| 33 | 21 | if ($dirname === '') { |
|
| 34 | 6 | throw new RootViolationException('Root directories can not be deleted.'); |
|
| 35 | } |
||
| 36 | |||
| 37 | 15 | $adapter = $this->filesystem->getAdapter(); |
|
| 38 | |||
| 39 | 15 | if ($options & STREAM_MKDIR_RECURSIVE) { |
|
| 40 | // I don't know how this gets triggered. |
||
| 41 | 3 | return (bool) $adapter->deleteDir($dirname); |
|
| 42 | } |
||
| 43 | |||
| 44 | 12 | $contents = $this->filesystem->listContents($dirname); |
|
| 45 | |||
| 46 | 12 | if ( ! empty($contents)) { |
|
| 47 | 12 | throw new DirectoryNotEmptyException(); |
|
| 48 | } |
||
| 49 | |||
| 50 | 6 | return (bool) $adapter->deleteDir($dirname); |
|
| 51 | } |
||
| 52 | } |
||
| 53 |