Completed
Pull Request — master (#151)
by Ihor
13:44
created

FixturesLoader::getFixtures()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace AppBundle\DataFixtures\ORM;
4
5
class FixturesLoader extends LoadData
6
{
7
    const FIXTURES_EXT = 'yml';
8
9
    /** @var array */
10
    private $fixturesPaths = [];
11
12
    /** @var  string */
13
    private $fixtureSourceDir;
14
15
    public function __construct($dir = null)
16
    {
17
        $dirName = empty($dir) ? '' : $dir.DIRECTORY_SEPARATOR;
18
        $this->fixtureSourceDir = __DIR__.DIRECTORY_SEPARATOR.$dirName;
19
    }
20
21
    /**
22
     * @param string $fixtureName
23
     * @param string:null $dir
0 ignored issues
show
Documentation introduced by
The doc-type string:null could not be parsed: Unknown type name "string:null" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
Bug introduced by
There is no parameter named $dir. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
24
     *
25
     * @throws \Exception
26
     */
27
    public function addFixture(string $fixtureName)
28
    {
29
        $fixturePath = sprintf('%s%s.%s', $this->fixtureSourceDir, $fixtureName, self::FIXTURES_EXT);
30
31
        if (!file_exists($fixturePath)) {
32
            throw new \Exception("Fixture path not found: {$fixturePath}");
33
        }
34
35
        $this->fixturesPaths[] = $fixturePath;
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    protected function getFixtures()
42
    {
43
        return $this->fixturesPaths;
44
    }
45
}
46