Passed
Pull Request — master (#8)
by Dmitriy
28:38 queued 13:30
created

Constants   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 30
rs 10
c 1
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A loadFile() 0 8 2
A constantsRequires() 0 3 1
A buildRequires() 0 8 2
A paramsRequires() 0 3 1
1
<?php
2
3
namespace Yiisoft\Composer\Config\Configs;
4
5
/**
6
 * Defines class represents output configuration file with constant definitions.
7
 */
8
class Constants extends Config
9
{
10
    protected function loadFile($path): array
11
    {
12
        parent::loadFile($path);
13
        if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') {
14
            return [];
15
        }
16
17
        return [$path];
18
    }
19
20
    public function buildRequires(): string
21
    {
22
        $res = [];
23
        foreach ($this->values as $path) {
24
            $res[] = "require_once '$path';";
25
        }
26
27
        return implode("\n", $res);
28
    }
29
30
    public function constantsRequires(): bool
31
    {
32
        return false;
33
    }
34
35
    public function paramsRequires(): bool
36
    {
37
        return false;
38
    }
39
}
40