Passed
Push — master ( 14a42b...4e4f6b )
by Andrii
02:16
created

Defines   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 18
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadFile() 0 11 2
A writeFile() 0 3 1
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)
21
    {
22
        parent::loadFile($path);
23
        if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') {
24
            return [];
25
        }
26
27
        $lines = file($path);
28
        array_shift($lines);
0 ignored issues
show
Bug introduced by
It seems like $lines can also be of type false; however, parameter $array of array_shift() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

28
        array_shift(/** @scrutinizer ignore-type */ $lines);
Loading history...
29
30
        return $lines;
31
    }
32
33
    protected function writeFile(string $path, array $data)
34
    {
35
        static::putFile($path, "<?php\n\n" . trim(implode('', $data)));
36
    }
37
}
38