Section::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusCmsPlugin\Entity;
12
13
use Sylius\Component\Resource\Model\TranslatableTrait;
14
use Sylius\Component\Resource\Model\TranslationInterface;
15
16
class Section implements SectionInterface
17
{
18
    use TranslatableTrait {
19
        __construct as private initializeTranslationsCollection;
20
    }
21
22
    /** @var int */
23
    protected $id;
24
25
    /** @var string|null */
26
    protected $code;
27
28
    public function __construct()
29
    {
30
        $this->initializeTranslationsCollection();
31
    }
32
33
    public function getId(): ?int
34
    {
35
        return $this->id;
36
    }
37
38
    public function getCode(): ?string
39
    {
40
        return $this->code;
41
    }
42
43
    public function setCode(?string $code): void
44
    {
45
        $this->code = $code;
46
    }
47
48
    public function getName(): ?string
49
    {
50
        /** @var SectionTranslationInterface $sectionTranslationInterface */
51
        $sectionTranslationInterface = $this->getSectionTranslation();
52
53
        return $sectionTranslationInterface->getName();
54
    }
55
56
    public function setName(?string $name): void
57
    {
58
        /** @var SectionTranslationInterface $sectionTranslationInterface */
59
        $sectionTranslationInterface = $this->getSectionTranslation();
60
        $sectionTranslationInterface->setName($name);
61
    }
62
63
    /**
64
     * @return TranslationInterface|SectionTranslationInterface
65
     */
66
    protected function getSectionTranslation(): TranslationInterface
67
    {
68
        return $this->getTranslation();
69
    }
70
71
    protected function createTranslation(): TranslationInterface
72
    {
73
        return new SectionTranslation();
74
    }
75
}
76