Block   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 102
rs 10
c 0
b 0
f 0
wmc 12

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getCode() 0 3 1
A getId() 0 3 1
A getName() 0 6 1
A getBlockTranslation() 0 3 1
A getLink() 0 6 1
A setLink() 0 5 1
A setName() 0 5 1
A setContent() 0 5 1
A getContent() 0 6 1
A createTranslation() 0 3 1
A setCode() 0 3 1
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\ToggleableTrait;
14
use Sylius\Component\Resource\Model\TranslatableTrait;
15
use Sylius\Component\Resource\Model\TranslationInterface;
16
17
class Block implements BlockInterface
18
{
19
    use ToggleableTrait;
20
21
    use SectionableTrait;
22
23
    use ProductsAwareTrait;
24
25
    use TaxonAwareTrait;
26
27
    use ChannelsAwareTrait;
28
29
    use TranslatableTrait {
30
        __construct as protected initializeTranslationsCollection;
31
    }
32
33
    public function __construct()
34
    {
35
        $this->initializeTranslationsCollection();
36
        $this->initializeSectionsCollection();
37
        $this->initializeProductsCollection();
38
        $this->initializeTaxonCollection();
39
        $this->initializeChannelsCollection();
40
    }
41
42
    /** @var int|null */
43
    protected $id;
44
45
    /** @var string|null */
46
    protected $code;
47
48
    public function getId(): ?int
49
    {
50
        return $this->id;
51
    }
52
53
    public function getCode(): ?string
54
    {
55
        return $this->code;
56
    }
57
58
    public function setCode(?string $code): void
59
    {
60
        $this->code = $code;
61
    }
62
63
    public function getName(): ?string
64
    {
65
        /** @var BlockTranslationInterface $blockTranslationInterface */
66
        $blockTranslationInterface = $this->getBlockTranslation();
67
68
        return $blockTranslationInterface->getName();
69
    }
70
71
    public function setName(?string $name): void
72
    {
73
        /** @var BlockTranslationInterface $blockTranslationInterface */
74
        $blockTranslationInterface = $this->getBlockTranslation();
75
        $blockTranslationInterface->setName($name);
76
    }
77
78
    public function getContent(): ?string
79
    {
80
        /** @var BlockTranslationInterface $blockTranslationInterface */
81
        $blockTranslationInterface = $this->getBlockTranslation();
82
83
        return $blockTranslationInterface->getContent();
84
    }
85
86
    public function setContent(?string $content): void
87
    {
88
        /** @var BlockTranslationInterface $blockTranslationInterface */
89
        $blockTranslationInterface = $this->getBlockTranslation();
90
        $blockTranslationInterface->setContent($content);
91
    }
92
93
    public function getLink(): ?string
94
    {
95
        /** @var BlockTranslationInterface $blockTranslationInterface */
96
        $blockTranslationInterface = $this->getBlockTranslation();
97
98
        return $blockTranslationInterface->getLink();
99
    }
100
101
    public function setLink(?string $link): void
102
    {
103
        /** @var BlockTranslationInterface $blockTranslationInterface */
104
        $blockTranslationInterface = $this->getBlockTranslation();
105
        $blockTranslationInterface->setLink($link);
106
    }
107
108
    /**
109
     * @return BlockTranslationInterface|TranslationInterface
110
     */
111
    protected function getBlockTranslation(): TranslationInterface
112
    {
113
        return $this->getTranslation();
114
    }
115
116
    protected function createTranslation(): BlockTranslationInterface
117
    {
118
        return new BlockTranslation();
119
    }
120
}
121