Passed
Push — master ( 04c37d...601b94 )
by Jason
02:36
created

updateGetIsAvailable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Dynamic\Foxy\Inventory\Extension;
4
5
use Dynamic\Foxy\Orders\Model\OrderDetail;
6
use Dynamic\Foxy\Orders\Model\OrderVariation;
7
use SilverStripe\ORM\ArrayList;
8
use SilverStripe\ORM\DataList;
9
10
class ProductVariationInventoryManager extends ProductInventoryManager
11
{
12
    /**
13
     * @return DataList
14
     */
15
    public function getOrders()
16
    {
17
        if ($this->owner->ID) {
18
            $orderVariations = OrderVariation::get()->filter('VariationID', $this->owner->ID);
19
            if ($orderVariations) {
0 ignored issues
show
introduced by
$orderVariations is of type SilverStripe\ORM\DataList, thus it always evaluated to true.
Loading history...
20
                $orders = ArrayList::create();
21
                foreach ($orderVariations as $orderVariation) {
22
                    $orderDetail = OrderDetail::get()->byID($orderVariation->OrderDetailID);
23
                    $orders->push($orderDetail);
24
                }
25
            }
26
27
            return $orders;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $orders does not seem to be defined for all execution paths leading up to this point.
Loading history...
28
29
        }
30
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type SilverStripe\ORM\DataList.
Loading history...
31
    }
32
33
    /**
34
     * @param $available
35
     */
36
    public function updateGetIsAvailable(&$available)
37
    {
38
        if ($this->getHasInventory()) {
39
            $available = $this->getIsProductAvailable();
40
        }
41
    }
42
}
43