Completed
Push — master ( 5d51b4...87fdd9 )
by Paul
10s
created

ArticleTranslation   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 138
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 8
c 3
b 1
f 1
lcom 0
cbo 1
dl 0
loc 138
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A setName() 0 6 1
A setSlug() 0 6 1
A getSlug() 0 4 1
A getDescription() 0 4 1
A setDescription() 0 6 1
A setImage() 0 6 1
A getImage() 0 4 1
1
<?php
2
3
namespace Victoire\Bundle\BlogBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Gedmo\Mapping\Annotation as Gedmo;
7
use JMS\Serializer\Annotation as Serializer;
8
use Knp\DoctrineBehaviors\Model\Translatable\Translation;
9
use Symfony\Component\Validator\Constraints as Assert;
10
use Victoire\Bundle\CoreBundle\Annotations as VIC;
11
use Victoire\Bundle\MediaBundle\Entity\Media;
12
13
/**
14
 * Victoire ViewTranslation.
15
 *
16
 * @ORM\Entity()
17
 * @ORM\Table(name="vic_article_translations")
18
 */
19
class ArticleTranslation
20
{
21
    use Translation;
22
23
    /**
24
     * @var string
25
     *
26
     * @Assert\NotBlank()
27
     * @ORM\Column(name="name", type="string", length=255)
28
     * @Serializer\Groups({"search"})
29
     * @VIC\BusinessProperty({"textable", "businessParameter", "seoable"})
30
     */
31
    protected $name;
32
33
    /**
34
     * @var string
35
     *
36
     * @Gedmo\Slug(handlers={
37
     *     @Gedmo\SlugHandler(class="Victoire\Bundle\BusinessEntityBundle\Handler\TwigSlugHandler"
38
     * )},fields={"name"}, updatable=false, unique=false)
39
     * @ORM\Column(name="slug", type="string", length=255)
40
     * @VIC\BusinessProperty("businessParameter")
41
     */
42
    protected $slug;
43
44
    /**
45
     * @var string
46
     *
47
     * @ORM\ManyToOne(targetEntity="\Victoire\Bundle\MediaBundle\Entity\Media")
48
     * @ORM\JoinColumn(name="image_id", referencedColumnName="id", onDelete="CASCADE")
49
     * @VIC\BusinessProperty("imageable")
50
     */
51
    private $image;
52
53
    /**
54
     * @var string
55
     *
56
     * @ORM\Column(name="description", type="text", nullable=true)
57
     * @VIC\BusinessProperty({"textable", "seoable"})
58
     */
59
    private $description;
60
61
    /**
62
     * Get name.
63
     *
64
     * @return string
65
     */
66
    public function getName()
67
    {
68
        return $this->name;
69
    }
70
71
    /**
72
     * Set name.
73
     *
74
     * @param string $name
75
     *
76
     * @return View
77
     */
78
    public function setName($name)
79
    {
80
        $this->name = $name;
81
82
        return $this;
83
    }
84
85
    /**
86
     * Set slug.
87
     *
88
     * @param string $slug
89
     *
90
     * @return View
91
     */
92
    public function setSlug($slug)
93
    {
94
        $this->slug = $slug;
95
96
        return $this;
97
    }
98
99
    /**
100
     * Get slug.
101
     *
102
     * @return string
103
     */
104
    public function getSlug()
105
    {
106
        return $this->slug;
107
    }
108
109
    /**
110
     * Get description.
111
     *
112
     * @return string
113
     */
114
    public function getDescription()
115
    {
116
        return $this->description;
117
    }
118
119
    /**
120
     * Set category.
121
     *
122
     * @param string $category
0 ignored issues
show
Bug introduced by
There is no parameter named $category. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
123
     *
124
     * @return Article
125
     */
126
    public function setDescription($description)
127
    {
128
        $this->description = $description;
129
130
        return $this;
131
    }
132
133
    /**
134
     * Set image.
135
     *
136
     * @param Media $image
137
     *
138
     * @return ArticleTranslation
139
     */
140
    public function setImage(Media $image = null)
141
    {
142
        $this->image = $image;
0 ignored issues
show
Documentation Bug introduced by
It seems like $image can also be of type object<Victoire\Bundle\MediaBundle\Entity\Media>. However, the property $image is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
143
144
        return $this;
145
    }
146
147
    /**
148
     * Get image.
149
     *
150
     * @return string
151
     */
152
    public function getImage()
153
    {
154
        return $this->image;
155
    }
156
}
157