| Conditions | 9 |
| Paths | 3 |
| Total Lines | 40 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 29 |
| CRAP Score | 9 |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 50 | 24 | protected function findAllResourceOptions(ResourceDOInterface $resourceDO) |
|
| 51 | { |
||
| 52 | /** @var \League\Flysystem\FilesystemInterface $filesystem */ |
||
| 53 | 24 | $filesystem = $this->filesystem; |
|
| 54 | 24 | $uuid = $resourceDO->getUuid(); |
|
|
1 ignored issue
–
show
|
|||
| 55 | 24 | $type = $resourceDO->getType(); |
|
|
1 ignored issue
–
show
|
|||
| 56 | 24 | $name = $resourceDO->getName(); |
|
|
1 ignored issue
–
show
|
|||
| 57 | 24 | if (!$name || !$type) { |
|
| 58 | 4 | throw new CommandErrorException('Can not look for options: resource is empty'); |
|
| 59 | } |
||
| 60 | 20 | $basename = $resourceDO->getBaseDirectory(); |
|
|
1 ignored issue
–
show
|
|||
| 61 | 20 | $namespace = $resourceDO->getNamespace(); |
|
| 62 | $path = $basename |
||
|
1 ignored issue
–
show
|
|||
| 63 | 20 | . ($namespace ? $namespace . DIRECTORY_SEPARATOR : '') |
|
| 64 | 20 | . $type . DIRECTORY_SEPARATOR |
|
| 65 | 20 | ; |
|
| 66 | 20 | $found = $filesystem->listContents($path, true); |
|
|
1 ignored issue
–
show
|
|||
| 67 | 20 | $found = array_filter($found, function($file) use ($uuid, $type) { |
|
|
1 ignored issue
–
show
|
|||
| 68 | |||
| 69 | 19 | return array_key_exists('filename', $file) |
|
| 70 | 19 | && $file['filename'] === $uuid |
|
| 71 | 19 | && array_key_exists('extension', $file) |
|
| 72 | 19 | && $file['extension'] === $type |
|
| 73 | 19 | && array_key_exists('type', $file) |
|
| 74 | // Warning: type field will be replaced by resource |
||
| 75 | 19 | && $file['type'] === 'file' |
|
| 76 | |||
| 77 | 19 | ; |
|
| 78 | 20 | }); |
|
| 79 | 20 | array_walk( |
|
| 80 | $found |
||
| 81 | 20 | , [$this, 'hydrateElementFile'] |
|
| 82 | 20 | , [ |
|
| 83 | 20 | 'resourceDO' => $resourceDO, |
|
| 84 | ] |
||
| 85 | 20 | ); |
|
| 86 | 20 | $found = array_values($found); // reset keys |
|
| 87 | |||
| 88 | 20 | return $found; |
|
| 89 | } |
||
| 90 | |||
| 139 | } |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.