ComposerFile   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 27
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 21 4
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