GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 079d9d...6c83ba )
by Odiseo
06:17
created

ArticleCategory::createTranslation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
cc 1
eloc 1
c 2
b 1
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Odiseo\BlogBundle\Model;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\Common\Collections\Collection;
7
use Sylius\Component\Resource\Model\TimestampableTrait;
8
use Sylius\Component\Resource\Model\ToggleableTrait;
9
use Sylius\Component\Resource\Model\TranslatableTrait;
10
use Sylius\Component\Resource\Model\TranslationInterface;
11
12
/**
13
 * @author Diego D'amico <[email protected]>
14
 */
15
class ArticleCategory implements ArticleCategoryInterface
16
{
17
    use TimestampableTrait;
18
    use ToggleableTrait;
19
20
    use TranslatableTrait {
21
        __construct as private initializeTranslationsCollection;
22
        getTranslation as private doGetTranslation;
23
    }
24
25
    /**
26
     * @var mixed
27
     */
28
    protected $id;
29
30
    /**
31
     * @var string|null
32
     */
33
    protected $code;
34
35
    /**
36
     * @var Collection|ArticleInterface[]
37
     */
38
    protected $articles;
39
40
    public function __construct()
41
    {
42
        $this->initializeTranslationsCollection();
43
        $this->articles = new ArrayCollection();
44
        $this->createdAt = new \DateTime();
45
        $this->enabled = true;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function getId()
52
    {
53
        return $this->id;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function getCode(): ?string
60
    {
61
        return $this->code;
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function setCode(?string $code): void
68
    {
69
        $this->code = $code;
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75
    public function setSlug(string $slug): void
76
    {
77
        /** @var ArticleCategoryTranslationInterface $articleTranslation */
78
        $articleCategoryTranslation = $this->getTranslation();
79
80
        $articleCategoryTranslation->setSlug($slug);
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function getSlug()
87
    {
88
        return $this->getTranslation()->getSlug();
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94
    public function setTitle(string $title): void
95
    {
96
        /** @var ArticleCategoryTranslationInterface $articleTranslation */
97
        $articleCategoryTranslation = $this->getTranslation();
98
99
        $articleCategoryTranslation->setTitle($title);
100
    }
101
102
    /**
103
     * {@inheritdoc}
104
     */
105
    public function getTitle()
106
    {
107
        return $this->getTranslation()->getTitle();
108
    }
109
110
    /**
111
     * {@inheritdoc}
112
     */
113
    public function addArticle(ArticleInterface $article)
114
    {
115
        if (!$this->hasArticle($article)) {
116
            $this->articles->add($article);
117
        }
118
    }
119
120
    /**
121
     * {@inheritdoc}
122
     */
123
    public function removeArticle(ArticleInterface $article)
124
    {
125
        if ($this->hasArticle($article)) {
126
            $this->articles->removeElement($article);
127
        }
128
    }
129
130
    /**
131
     * {@inheritdoc}
132
     */
133
    public function hasArticle(ArticleInterface $article)
134
    {
135
        return $this->articles->contains($article);
136
    }
137
138
    /**
139
     * {@inheritdoc}
140
     */
141
    public function getArticles()
142
    {
143
        return $this->articles;
144
    }
145
146
    /**
147
     * {@inheritdoc}
148
     */
149
    public function getTranslation(?string $locale = null): TranslationInterface
150
    {
151
        /** @var ArticleCategoryTranslationInterface $translation */
152
        $translation = $this->doGetTranslation($locale);
153
154
        return $translation;
155
    }
156
157
    /**
158
     * {@inheritdoc}
159
     */
160
    protected function createTranslation(): ArticleCategoryTranslation
161
    {
162
        return new ArticleCategoryTranslation();
163
    }
164
165
    public function __toString()
166
    {
167
        return $this->getTitle();
168
    }
169
}
170