Completed
Push — to-be-a-hat-or-not-to-be-kuhwa ( b72886...e84c48 )
by Kamil
19:11
created

TaxonFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createNew() 0 4 1
A createForParent() 0 7 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\Component\Taxonomy\Factory;
13
14
use Sylius\Component\Resource\Factory\FactoryInterface;
15
use Sylius\Component\Taxonomy\Model\TaxonInterface;
16
17
/**
18
 * @author Mateusz Zalewski <[email protected]>
19
 */
20
final class TaxonFactory implements TaxonFactoryInterface
21
{
22
    /**
23
     * @var FactoryInterface
24
     */
25
    private $factory;
26
27
    /**
28
     * @param FactoryInterface $factory
29
     */
30
    public function __construct(FactoryInterface $factory)
31
    {
32
        $this->factory = $factory;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function createNew()
39
    {
40
        return $this->factory->createNew();
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function createForParent(TaxonInterface $parent)
47
    {
48
        $taxon = $this->createNew();
49
        $taxon->setParent($parent);
50
51
        return $taxon;
52
    }
53
}
54