ComposerFile::__invoke()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.0534
c 0
b 0
f 0
cc 4
eloc 11
nc 4
nop 1
1
<?php
2
3
namespace Knp\MegaMAN\Filter;
4
5
use Knp\MegaMAN\Filter;
6
7
class ComposerFile implements Filter
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12
    public function __invoke(array $array)
13
    {
14
        $result = [];
15
16
        foreach ($array as $definition) {
17
            if (false === array_key_exists('readme', $definition)) {
18
                continue;
19
            }
20
21
            $composer = sprintf('%s%scomposer.json', dirname($definition['readme']), DIRECTORY_SEPARATOR);
22
23
            if (false === file_exists($composer)) {
24
                continue;
25
            }
26
27
            $definition['composer'] = $composer;
28
            $result[]               = $definition;
29
        }
30
31
        return $result;
32
    }
33
}
34