Completed
Push — develop ( 141adb...8f70d4 )
by Jaap
05:39
created

Payload   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 39
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getApiConfig() 0 9 1
A withFiles() 0 4 1
A getFiles() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of phpDocumentor.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @author    Mike van Riel <[email protected]>
12
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
13
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
14
 * @link      http://phpdoc.org
15
 */
16
17
namespace phpDocumentor\Application\Stage\Parser;
18
19
use phpDocumentor\Application\Stage\Payload as ApplicationPayload;
20
use phpDocumentor\Descriptor\ProjectDescriptorBuilder;
21
use phpDocumentor\Reflection\File;
22
23
final class Payload extends ApplicationPayload
24
{
25
    /**
26
     * @var File[]
27
     */
28
    private $files;
29
30
    /**
31
     * @param File[] $files
32
     */
33
    public function __construct(array $config, ProjectDescriptorBuilder $builder, array $files = [])
34
    {
35
        parent::__construct($config, $builder);
36
        $this->files = $files;
37
    }
38
39
    public function getApiConfig()
40
    {
41
        //Grep only the first version for now. Multi version support will be added later
42
        $version = current($this->getConfig()['phpdocumentor']['versions']);
43
44
        //We are currently in the parser stage so grep the api config.
45
        //And for now we support a single api definition. Could be more in the future.
46
        return $version['api'][0];
47
    }
48
49
    public function withFiles(array $files) : Payload
50
    {
51
        return new self($this->getConfig(), $this->getBuilder(), $files);
52
    }
53
54
    /**
55
     * @return File[]
56
     */
57
    public function getFiles() : array
58
    {
59
        return $this->files;
60
    }
61
}
62