1 | <?php namespace Darryldecode\Cart; |
||
13 | class ItemCollection extends Collection |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * Sets the config parameters. |
||
18 | * |
||
19 | * @var |
||
20 | */ |
||
21 | protected $config; |
||
22 | |||
23 | /** |
||
24 | * ItemCollection constructor. |
||
25 | * @param array|mixed $items |
||
26 | * @param $config |
||
27 | */ |
||
28 | public function __construct($items, $config) |
||
34 | |||
35 | /** |
||
36 | * get the sum of price |
||
37 | * |
||
38 | * @return mixed|null |
||
39 | */ |
||
40 | public function getPriceSum() |
||
44 | |||
45 | public function __get($name) |
||
46 | { |
||
47 | if ($this->has($name) || $name == 'model') { |
||
48 | return !is_null($this->get($name)) ? $this->get($name) : $this->getAssociatedModel(); |
||
49 | } |
||
50 | return null; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * return the associated model of an item |
||
55 | * |
||
56 | * @return bool |
||
57 | */ |
||
58 | protected function getAssociatedModel() |
||
68 | |||
69 | /** |
||
70 | * check if item has conditions |
||
71 | * |
||
72 | * @return bool |
||
73 | */ |
||
74 | public function hasConditions() |
||
85 | |||
86 | /** |
||
87 | * check if item has conditions |
||
88 | * |
||
89 | * @return mixed|null |
||
90 | */ |
||
91 | public function getConditions() |
||
96 | |||
97 | /** |
||
98 | * get the single price in which conditions are already applied |
||
99 | * @param bool $formatted |
||
100 | * @return mixed|null |
||
101 | */ |
||
102 | public function getPriceWithConditions($formatted = true) |
||
123 | |||
124 | /** |
||
125 | * get the sum of price in which conditions are already applied |
||
126 | * @param bool $formatted |
||
127 | * @return mixed|null |
||
128 | */ |
||
129 | public function getPriceSumWithConditions($formatted = true) |
||
133 | } |
||
134 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.