1 | <?php |
||
7 | class Product extends AbstractHelper |
||
8 | { |
||
9 | protected $productUomService; |
||
10 | |||
11 | public function __invoke() |
||
15 | |||
16 | public function uomString($product) |
||
17 | { |
||
18 | if ($product->has('uoms')) { |
||
19 | $svc = $this->getProductUomService(); |
||
20 | $uom = $svc->cheapestUom($product->getUoms()); |
||
21 | $svc->populate($uom); |
||
22 | $moreThan1 = ($uom->getQuantity() > 1); |
||
23 | |||
24 | $string = $uom->getUom()->getName(); |
||
25 | if ($moreThan1) { |
||
26 | $string .= ' of ' . $uom->getQuantity(); |
||
27 | } |
||
28 | return $string; |
||
29 | } |
||
30 | // @TODO: if there are builders, get the uomString from the one we are |
||
31 | //displaying the price from |
||
32 | return 'Starting At'; |
||
33 | } |
||
34 | |||
35 | |||
36 | |||
37 | public function allUomsString($product, $string = true) |
||
38 | { |
||
39 | $uomStrings = array(); |
||
40 | |||
41 | if ($product->type() === 'product') { |
||
42 | foreach ($uoms as $uom) { |
||
|
|||
43 | $uomStrings[$this->uomStr($uom)] = $this->uomName($uom); |
||
44 | } |
||
45 | } elseif ($product->type() === 'shell') { |
||
46 | foreach ($product->getBuilders() as $builder) { |
||
47 | foreach ($builder->getProduct()->getUoms() as $uom) { |
||
48 | $uomStrings[$this->uomStr($uom)] = $this->uomName($uom); |
||
49 | } |
||
50 | } |
||
51 | } |
||
52 | |||
53 | if ($string) { |
||
54 | return implode(',', $uomStrings); |
||
55 | } |
||
56 | |||
57 | return $uomStrings; |
||
58 | } |
||
59 | |||
60 | public function uomStr($uom) |
||
64 | |||
65 | public function uomName($uom) |
||
66 | { |
||
67 | if ($uom->getQuantity() === 1) { |
||
68 | return $uom->getUom()->getName(); |
||
69 | } |
||
70 | return "{$uom->getUom()->getName()} of {$uom->getQuantity()}"; |
||
71 | } |
||
72 | |||
73 | public function itemNumbers($product, $implode = false) |
||
89 | |||
90 | public function getProductUomService() |
||
94 | |||
95 | public function setProductUomService($productUomService) |
||
96 | { |
||
97 | $this->productUomService = $productUomService; |
||
100 | } |
||
101 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.