Completed
Push — master ( 01b4b8...fc5086 )
by Kamil
19s
created

ProductImage   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 56
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A hasProductVariants() 0 4 1
A getProductVariants() 0 4 1
A hasProductVariant() 0 4 1
A addProductVariant() 0 4 1
A removeProductVariant() 0 6 2
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\Core\Model;
13
14
use Doctrine\Common\Collections\ArrayCollection;
15
use Doctrine\Common\Collections\Collection;
16
17
/**
18
 * @author Grzegorz Sadowski <[email protected]>
19
 */
20
class ProductImage extends Image implements ProductImageInterface
21
{
22
    /**
23
     * @var Collection|ProductVariantInterface[]
24
     */
25
    protected $productVariants;
26
27
    public function __construct()
28
    {
29
        parent::__construct();
30
31
        $this->productVariants = new ArrayCollection();
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function hasProductVariants()
38
    {
39
        return !$this->productVariants->isEmpty();
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function getProductVariants()
46
    {
47
        return $this->productVariants;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function hasProductVariant(ProductVariantInterface $productVariant)
54
    {
55
        return $this->productVariants->contains($productVariant);
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function addProductVariant(ProductVariantInterface $productVariant)
62
    {
63
        $this->productVariants->add($productVariant);
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function removeProductVariant(ProductVariantInterface $productVariant)
70
    {
71
        if ($this->hasProductVariant($productVariant)) {
72
            $this->productVariants->removeElement($productVariant);
73
        }
74
    }
75
}
76