Completed
Pull Request — master (#2)
by Tomáš
03:12
created

MultiCsFileLoader::getMultiCsFileLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of Symplify
5
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
6
 */
7
8
namespace Symplify\MultiCodingStandard\Configuration;
9
10
use Nette\Utils\Json;
11
use Symplify\MultiCodingStandard\Contract\Configuration\MultiCsFileLoaderInterface;
12
13
final class MultiCsFileLoader implements MultiCsFileLoaderInterface
14
{
15
    /**
16
     * @var string
17
     */
18
    const JSON_FILE_NAME = 'multi-cs.json';
19
20
    /**
21
     * @var string
22
     */
23
    private $baseDir;
24
25
    /**
26
     * @param string $baseDir
27
     */
28 4
    public function __construct($baseDir)
29
    {
30 4
        $this->baseDir = $baseDir;
31 4
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 4
    public function load()
37
    {
38 4
        $file = $this->getMultiCsFileLocation();
39 4
        $fileContent = file_get_contents($file);
40
41 4
        return Json::decode($fileContent, true);
0 ignored issues
show
Documentation introduced by
true is of type boolean, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
42
    }
43
44
    /**
45
     * @return string
46
     */
47 4
    private function getMultiCsFileLocation()
48
    {
49 4
        return $this->baseDir.'/'.self::JSON_FILE_NAME;
50
    }
51
}
52