Passed
Pull Request — master (#62)
by
unknown
07:39
created

Brand::getCreatedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Loevgaard\SyliusBrandPlugin\Model;
6
7
class Brand implements BrandInterface
8
{
9
    use ProductsAwareTrait {
10
        ProductsAwareTrait::__construct as private __productsAwareTraitConstruct;
11
    }
12
    use ImagesAwareTrait {
13
        ImagesAwareTrait::__construct as private __imagesAwareTraitConstruct;
14
    }
15
16
    /**
17
     * @var int
18
     */
19
    protected $id;
20
21
    /**
22
     * @var string|null
23
     */
24
    protected $code;
25
26
    /**
27
     * @var string|null
28
     */
29
    protected $name;
30
31
    /**
32
     * @var \DateTime
33
     */
34
    private $createdAt;
35
36
    /**
37
     * @var \DateTime
38
     */
39
    private $updatedAt;
40
41
    public function __construct()
42
    {
43
        $this->__imagesAwareTraitConstruct();
44
        $this->__productsAwareTraitConstruct();
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function __toString(): string
51
    {
52
        return (string) $this->getName();
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function getId(): ?int
59
    {
60
        return $this->id;
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function getCode(): ?string
67
    {
68
        return $this->code;
69
    }
70
71
    /**
72
     * @param string $code
73
     */
74
    public function setCode(?string $code): void
75
    {
76
        $this->code = $code;
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82
    public function getName(): ?string
83
    {
84
        return $this->name;
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function setName(?string $name): void
91
    {
92
        $this->name = $name;
93
    }
94
95
    /**
96
     * @return \DateTime
97
     */
98
    public function getCreatedAt(): \DateTime
99
    {
100
        return $this->createdAt;
101
    }
102
103
    /**
104
     * @return \DateTime
105
     */
106
    public function getUpdatedAt(): \DateTime
107
    {
108
        return $this->updatedAt;
109
    }
110
111
    public function addProduct(ProductInterface $product): void
112
    {
113
        if (!$this->hasProduct($product)) {
114
            $product->setBrand($this);
115
            $this->products->add($product);
116
        }
117
    }
118
119
    public function removeProduct(ProductInterface $product): void
120
    {
121
        if ($this->hasProduct($product)) {
122
            $product->setBrand(null);
123
            $this->products->removeElement($product);
124
        }
125
    }
126
}
127