PackageName::__invoke()   B
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 8.9197
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 PackageName 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('composer', $definition)) {
18
                continue;
19
            }
20
21
            $json = json_decode(file_get_contents($definition['composer']), true);
22
23
            if (false === array_key_exists('name', $json)) {
24
                continue;
25
            }
26
27
            $definition['package'] = $json['name'];
28
29
            $result[] = $definition;
30
        }
31
32
        return $result;
33
    }
34
}
35