These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of EC-CUBE |
||
5 | * |
||
6 | * Copyright(c) LOCKON CO.,LTD. All Rights Reserved. |
||
7 | * |
||
8 | * http://www.lockon.co.jp/ |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | namespace Eccube\Entity; |
||
15 | |||
16 | use Doctrine\ORM\Mapping as ORM; |
||
17 | |||
18 | 1 | if (!class_exists('\Eccube\Entity\CartItem')) { |
|
19 | /** |
||
20 | * CartItem |
||
21 | * |
||
22 | * @ORM\Table(name="dtb_cart_item") |
||
23 | * @ORM\InheritanceType("SINGLE_TABLE") |
||
24 | * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255) |
||
25 | * @ORM\HasLifecycleCallbacks() |
||
26 | * @ORM\Entity(repositoryClass="Eccube\Repository\CartItemRepository") |
||
27 | */ |
||
28 | class CartItem extends \Eccube\Entity\AbstractEntity implements ItemInterface |
||
29 | { |
||
30 | use PointRateTrait; |
||
31 | |||
32 | /** |
||
33 | * @var integer |
||
34 | * |
||
35 | * @ORM\Column(name="id", type="integer", options={"unsigned":true}) |
||
36 | * @ORM\Id |
||
37 | * @ORM\GeneratedValue(strategy="IDENTITY") |
||
38 | */ |
||
39 | private $id; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | * |
||
44 | * @ORM\Column(name="price", type="decimal", precision=12, scale=2, options={"default":0}) |
||
45 | */ |
||
46 | private $price = 0; |
||
47 | |||
48 | /** |
||
49 | * @var string |
||
50 | * |
||
51 | * @ORM\Column(name="quantity", type="decimal", precision=10, scale=0, options={"default":0}) |
||
52 | */ |
||
53 | private $quantity = 0; |
||
54 | |||
55 | /** |
||
56 | * @var \Eccube\Entity\ProductClass |
||
57 | * |
||
58 | * @ORM\ManyToOne(targetEntity="Eccube\Entity\ProductClass") |
||
59 | * @ORM\JoinColumns({ |
||
60 | * @ORM\JoinColumn(name="product_class_id", referencedColumnName="id") |
||
61 | * }) |
||
62 | */ |
||
63 | private $ProductClass; |
||
64 | |||
65 | /** |
||
66 | * @var \Eccube\Entity\Cart |
||
67 | * |
||
68 | * @ORM\ManyToOne(targetEntity="Eccube\Entity\Cart", inversedBy="CartItems") |
||
69 | * @ORM\JoinColumns({ |
||
70 | * @ORM\JoinColumn(name="cart_id", referencedColumnName="id", onDelete="CASCADE") |
||
71 | * }) |
||
72 | */ |
||
73 | private $Cart; |
||
74 | |||
75 | /** |
||
76 | * sessionのシリアライズのために使われる |
||
77 | * |
||
78 | * @var int |
||
79 | */ |
||
80 | private $product_class_id; |
||
81 | |||
82 | public function __sleep() |
||
83 | { |
||
84 | return ['product_class_id', 'price', 'quantity']; |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * @return int |
||
89 | */ |
||
90 | public function getId() |
||
91 | { |
||
92 | 92 | return $this->id; |
|
93 | } |
||
94 | 92 | ||
95 | /** |
||
96 | 92 | * @param integer $price |
|
97 | * |
||
98 | * @return CartItem |
||
99 | */ |
||
100 | public function setPrice($price) |
||
101 | { |
||
102 | 82 | $this->price = $price; |
|
0 ignored issues
–
show
|
|||
103 | |||
104 | 82 | return $this; |
|
105 | } |
||
106 | |||
107 | /** |
||
108 | * @return string |
||
109 | */ |
||
110 | public function getPrice() |
||
111 | { |
||
112 | 95 | return $this->price; |
|
113 | } |
||
114 | 95 | ||
115 | /** |
||
116 | 95 | * @param integer $quantity |
|
117 | * |
||
118 | * @return CartItem |
||
119 | */ |
||
120 | public function setQuantity($quantity) |
||
121 | { |
||
122 | 91 | $this->quantity = $quantity; |
|
0 ignored issues
–
show
The property
$quantity was declared of type string , but $quantity is of type integer . Maybe add a type cast?
This check looks for assignments to scalar types that may be of the wrong type. To ensure the code behaves as expected, it may be a good idea to add an explicit type cast. $answer = 42;
$correct = false;
$correct = (bool) $answer;
Loading history...
|
|||
123 | |||
124 | 91 | return $this; |
|
125 | } |
||
126 | |||
127 | /** |
||
128 | * @return string |
||
129 | */ |
||
130 | 16 | public function getQuantity() |
|
131 | { |
||
132 | 16 | return $this->quantity; |
|
133 | } |
||
134 | |||
135 | /** |
||
136 | * @return integer |
||
137 | */ |
||
138 | public function getTotalPrice() |
||
139 | { |
||
140 | 89 | return $this->getPrice() * $this->getQuantity(); |
|
141 | } |
||
142 | 89 | ||
143 | /** |
||
144 | * 商品明細かどうか. |
||
145 | * |
||
146 | * @return boolean 商品明細の場合 true |
||
147 | */ |
||
148 | public function isProduct() |
||
149 | { |
||
150 | 79 | return true; |
|
151 | } |
||
152 | 79 | ||
153 | /** |
||
154 | * 送料明細かどうか. |
||
155 | * |
||
156 | * @return boolean 送料明細の場合 true |
||
157 | */ |
||
158 | public function isDeliveryFee() |
||
159 | { |
||
160 | 79 | return false; |
|
161 | } |
||
162 | 79 | ||
163 | /** |
||
164 | * 手数料明細かどうか. |
||
165 | * |
||
166 | * @return boolean 手数料明細の場合 true |
||
167 | */ |
||
168 | public function isCharge() |
||
169 | { |
||
170 | 79 | return false; |
|
171 | } |
||
172 | 79 | ||
173 | /** |
||
174 | * 値引き明細かどうか. |
||
175 | * |
||
176 | * @return boolean 値引き明細の場合 true |
||
177 | */ |
||
178 | public function isDiscount() |
||
179 | { |
||
180 | return false; |
||
181 | } |
||
182 | |||
183 | /** |
||
184 | * 税額明細かどうか. |
||
185 | * |
||
186 | * @return boolean 税額明細の場合 true |
||
187 | */ |
||
188 | public function isTax() |
||
189 | { |
||
190 | 79 | return false; |
|
191 | } |
||
192 | 79 | ||
193 | /** |
||
194 | * ポイント明細かどうか. |
||
195 | 17 | * |
|
196 | * @return boolean ポイント明細の場合 true |
||
197 | */ |
||
198 | 17 | public function isPoint() |
|
199 | { |
||
200 | 17 | return false; |
|
201 | } |
||
202 | |||
203 | public function getOrderItemType() |
||
204 | { |
||
205 | // TODO OrderItemType::PRODUCT |
||
206 | $ItemType = new \Eccube\Entity\Master\OrderItemType(); |
||
207 | |||
208 | 110 | return $ItemType; |
|
209 | } |
||
210 | 110 | ||
211 | /** |
||
212 | 110 | * @param ProductClass $ProductClass |
|
213 | 110 | * |
|
214 | * @return $this |
||
215 | 110 | */ |
|
216 | public function setProductClass(ProductClass $ProductClass) |
||
217 | { |
||
218 | $this->ProductClass = $ProductClass; |
||
219 | |||
220 | $this->product_class_id = is_object($ProductClass) ? |
||
221 | 103 | $ProductClass->getId() : null; |
|
222 | |||
223 | 103 | return $this; |
|
224 | } |
||
225 | |||
226 | /** |
||
227 | * @return ProductClass |
||
228 | */ |
||
229 | 37 | public function getProductClass() |
|
230 | { |
||
231 | 37 | return $this->ProductClass; |
|
232 | } |
||
233 | |||
234 | 79 | /** |
|
235 | * @return int|null |
||
236 | */ |
||
237 | 79 | public function getProductClassId() |
|
238 | { |
||
239 | return $this->product_class_id; |
||
240 | } |
||
241 | |||
242 | public function getPriceIncTax() |
||
243 | { |
||
244 | // TODO ItemInterfaceに追加, Cart::priceは税込み金額が入っているので,フィールドを分ける必要がある |
||
245 | return $this->price; |
||
246 | } |
||
247 | |||
248 | /** |
||
249 | * @return Cart |
||
250 | */ |
||
251 | 88 | public function getCart() |
|
252 | { |
||
253 | 88 | return $this->Cart; |
|
254 | } |
||
255 | |||
256 | /** |
||
257 | * @param Cart $Cart |
||
258 | */ |
||
259 | public function setCart(Cart $Cart) |
||
260 | { |
||
261 | $this->Cart = $Cart; |
||
262 | } |
||
263 | } |
||
264 | } |
||
265 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.