Completed
Push — master ( ef8a42...b5fe4d )
by Andrii
15:02
created

Defines::writeFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
/**
3
 * Composer plugin for config assembling
4
 *
5
 * @link      https://github.com/hiqdev/composer-config-plugin
6
 * @package   composer-config-plugin
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\composer\config\configs;
12
13
/**
14
 * Defines class represents output configuration file with constant definitions.
15
 *
16
 * @author Andrii Vasyliev <[email protected]>
17
 */
18
class Defines extends Config
19
{
20
    protected function loadFile($path): array
21
    {
22
        parent::loadFile($path);
23
        if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') {
24
            return [];
25
        }
26
27
        return [$path];
28
    }
29
30
    public function buildRequires(): string
31
    {
32
        $res = [];
33
        foreach ($this->values as $path) {
34
            $res[] = "require_once '$path';";
35
        }
36
37
        return implode("\n", $res);
38
    }
39
}
40