Completed
Push — master ( fecb59...e32f72 )
by Paweł
29:36
created

Item::getPackage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher Bridge Component.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Component\Bridge\Model;
16
17
use Doctrine\Common\Collections\ArrayCollection;
18
use SWP\Component\Common\Model\TimestampableInterface;
19
use SWP\Component\Common\Model\TimestampableTrait;
20
21
class Item extends BaseContent implements ItemInterface, TimestampableInterface
22
{
23
    use TimestampableTrait;
24
25
    /**
26
     * @var string
27
     */
28
    protected $body;
29
30
    /**
31
     * @var string
32
     */
33
    protected $bodyText;
34
35
    /**
36
     * Collection.
37
     */
38
    protected $renditions;
39
40
    /**
41
     * @var string
42
     */
43
    protected $usageTerms;
44
45
    /**
46
     * @var ArrayCollection
47
     */
48
    public $items;
49
50
    /**
51
     * @var Package
52
     */
53
    protected $package;
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 12
    public function getBody()
59
    {
60 12
        return $this->body;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function setBody($body)
67
    {
68
        $this->body = $body;
69
    }
70
71
    /**
72
     * @param ArrayCollection $renditions
73
     */
74
    public function setRenditions($renditions)
75
    {
76
        $this->renditions = $renditions;
77
    }
78
79
    /**
80
     * @return ArrayCollection
81
     */
82 3
    public function getRenditions()
83
    {
84 3
        return $this->renditions;
85
    }
86
87
    /**
88
     * @return ArrayCollection
89
     */
90 11
    public function getItems()
91
    {
92 11
        return $this->items;
93
    }
94
95
    /**
96
     * @param ArrayCollection $items
97
     */
98
    public function setItems($items)
99
    {
100
        $this->items = $items;
101
    }
102
103
    /**
104
     * @return string
105
     */
106 4
    public function getBodyText()
107
    {
108 4
        return $this->bodyText;
109
    }
110
111
    /**
112
     * @param string $bodyText
113
     */
114
    public function setBodyText($bodyText)
115
    {
116
        $this->bodyText = $bodyText;
117
    }
118
119
    /**
120
     * @return string
121
     */
122 4
    public function getUsageTerms()
123
    {
124 4
        return $this->usageTerms;
125
    }
126
127
    /**
128
     * @param string $usageTerms
129
     */
130
    public function setUsageTerms($usageTerms)
131
    {
132
        $this->usageTerms = $usageTerms;
133
    }
134
135
    /**
136
     * Set package.
137
     *
138
     * @param PackageInterface|void $package
139
     *
140
     * @return Item
141
     */
142 11
    public function setPackage(PackageInterface $package = null)
143
    {
144 11
        $this->package = $package;
0 ignored issues
show
Documentation Bug introduced by
It seems like $package can also be of type object<SWP\Component\Bri...Model\PackageInterface>. However, the property $package is declared as type object<SWP\Component\Bridge\Model\Package>. 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...
145 11
    }
146
147
    /**
148
     * Get package.
149
     *
150
     * @return Package
151
     */
152
    public function getPackage()
153
    {
154
        return $this->package;
155
    }
156
}
157