Completed
Push — master ( 4c7b9c...e919dc )
by Kamil
21:11
created

FixtureRegistry   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 37
rs 10
c 3
b 1
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addFixture() 0 6 1
A getFixture() 0 8 2
A getFixtures() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\FixturesBundle\Fixture;
13
14
use Webmozart\Assert\Assert;
15
16
/**
17
 * @author Kamil Kokot <[email protected]>
18
 */
19
final class FixtureRegistry implements FixtureRegistryInterface
20
{
21
    /**
22
     * @var array
23
     */
24
    private $fixtures = [];
25
26
    /**
27
     * @param FixtureInterface $fixture
28
     */
29
    public function addFixture(FixtureInterface $fixture)
30
    {
31
        Assert::keyNotExists($this->fixtures, $fixture->getName(), 'Fixture with name "%s" is already registered.');
32
33
        $this->fixtures[$fixture->getName()] = $fixture;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function getFixture($name)
40
    {
41
        if (!isset($this->fixtures[$name])) {
42
            throw new FixtureNotFoundException($name);
43
        }
44
45
        return $this->fixtures[$name];
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function getFixtures()
52
    {
53
        return $this->fixtures;
54
    }
55
}
56