Completed
Push — wip-platform ( 03cba6...2999ab )
by
unknown
05:53 queued 02:49
created

PatcherConfig::loadConfig()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 0
1
<?php
2
3
/*
4
 *
5
 * Copyright (C) 2015-2017 Libre Informatique
6
 *
7
 * This file is licenced under the GNU LGPL v3.
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Blast\Bundle\CoreBundle\Command;
13
14
use Symfony\Component\Yaml\Yaml;
15
16
trait PatcherConfig
17
{
18
    private $config;
19
20
    private function loadConfig()
21
    {
22
        $configPath = __DIR__ . '/../Tools/Patches/patches.yml';
23
24
        $this->config = Yaml::parse(
25
            file_get_contents($configPath)
26
        );
27
28
        if ($this->config['patches'] == null) {
29
            $this->config['patches'] = [];
30
        }
31
32
        $this->config['paths'] = [
33
            'patchFilesDir' => __DIR__ . '/../Tools/Patches/patches',
34
            'rootDir'       => str_replace('/app/..', '', $this->getContainer()->getParameter('kernel.root_dir') . '/..'),
0 ignored issues
show
Bug introduced by
It seems like getContainer() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
35
            'configFile'    => $configPath,
36
        ];
37
    }
38
}
39