Completed
Push — master ( d99440...b71151 )
by Hunter
13:25
created

ProcessSchemaFiles   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 10 1
1
<?php namespace HSkrasek\OpenAPI\Command\Stages;
2
3
use League\Pipeline\Pipeline;
4
use League\Pipeline\StageInterface;
5
6
class ProcessSchemaFiles implements StageInterface
7
{
8
    /**
9
     * @var Pipeline
10
     */
11
    private $pipeline;
12
13
    public function __construct(Pipeline $pipeline)
14
    {
15
        $this->pipeline = $pipeline;
16
    }
17
18
    /**
19
     * @inheritDoc
20
     */
21
    public function __invoke($payload)
22
    {
23
        $payload[0] = array_reduce($payload[0], function (array $carry, array $openApiSchemaFile) {
24
            $carry[$openApiSchemaFile['filename'] . '.json'] = $this->pipeline->process($openApiSchemaFile);
25
26
            return $carry;
27
        }, []);
28
29
        return $payload;
30
    }
31
}
32