ArticleTranslation::getImage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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", "seoable"})
30
     */
31
    protected $name;
32
33
    /**
34
     * @var string
35
     *
36
     * @Assert\NotBlank(groups={"edition"})
37
     * @Gedmo\Slug(handlers={
38
     *     @Gedmo\SlugHandler(class="Victoire\Bundle\BusinessEntityBundle\Handler\TwigSlugHandler"
39
     * )},fields={"name"}, updatable=false, unique=false)
40
     * @ORM\Column(name="slug", type="string", length=255)
41
     * @VIC\BusinessProperty("businessParameter")
42
     */
43
    protected $slug;
44
45
    /**
46
     * @var string
47
     *
48
     * @ORM\ManyToOne(targetEntity="\Victoire\Bundle\MediaBundle\Entity\Media")
49
     * @ORM\JoinColumn(name="image_id", referencedColumnName="id", onDelete="CASCADE")
50
     * @VIC\BusinessProperty("imageable")
51
     */
52
    private $image;
53
54
    /**
55
     * @var string
56
     *
57
     * @ORM\Column(name="description", type="text", nullable=true)
58
     * @VIC\BusinessProperty({"textable", "seoable"})
59
     */
60
    private $description;
61
62
    /**
63
     * Get name.
64
     *
65
     * @return string
66
     */
67
    public function getName()
68
    {
69
        return $this->name;
70
    }
71
72
    /**
73
     * Set name.
74
     *
75
     * @param string $name
76
     *
77
     * @return View
78
     */
79
    public function setName($name)
80
    {
81
        $this->name = $name;
82
83
        return $this;
84
    }
85
86
    /**
87
     * Set slug.
88
     *
89
     * @param string $slug
90
     *
91
     * @return View
92
     */
93
    public function setSlug($slug)
94
    {
95
        $this->slug = $slug;
96
97
        return $this;
98
    }
99
100
    /**
101
     * Get slug.
102
     *
103
     * @return string
104
     */
105
    public function getSlug()
106
    {
107
        return $this->slug;
108
    }
109
110
    /**
111
     * Get description.
112
     *
113
     * @return string
114
     */
115
    public function getDescription()
116
    {
117
        return $this->description;
118
    }
119
120
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$description" missing
Loading history...
121
     * Set category.
122
     *
123
     * @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...
introduced by
Doc comment for parameter $category does not match actual variable name $description
Loading history...
124
     *
125
     * @return Article
126
     */
127
    public function setDescription($description)
128
    {
129
        $this->description = $description;
130
131
        return $this;
132
    }
133
134
    /**
135
     * Set image.
136
     *
137
     * @param Media $image
138
     *
139
     * @return ArticleTranslation
140
     */
141
    public function setImage(Media $image = null)
142
    {
143
        $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...
144
145
        return $this;
146
    }
147
148
    /**
149
     * Get image.
150
     *
151
     * @return string
152
     */
153
    public function getImage()
154
    {
155
        return $this->image;
156
    }
157
}
158