| Total Complexity | 5 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class GetCustomerEquipment |
||
| 12 | { |
||
| 13 | protected $custID; |
||
| 14 | |||
| 15 | 6 | public function __construct($custID) |
|
| 16 | { |
||
| 17 | 6 | $this->custID = $custID; |
|
| 18 | 6 | } |
|
| 19 | |||
| 20 | // Get all equipment types that are assigned to the customer |
||
| 21 | 6 | public function execute() |
|
| 22 | { |
||
| 23 | 6 | $hasParent = Customers::findOrFail($this->custID)->parent_id; |
|
| 24 | 4 | $localEquip = $this->getLocalEquipment(); |
|
| 25 | |||
| 26 | 4 | if($hasParent) |
|
| 27 | { |
||
| 28 | 2 | $parentEquip = $this->getParentEquipment($hasParent); |
|
| 29 | 2 | return $localEquip->merge($parentEquip); |
|
| 30 | } |
||
| 31 | 2 | return $localEquip; |
|
| 32 | } |
||
| 33 | |||
| 34 | // Retrieve any equipment attached to the customer |
||
| 35 | 4 | protected function getLocalEquipment() |
|
| 43 | } |
||
| 44 | |||
| 45 | // Retrieve any equipment attached to the parent customer |
||
| 46 | 2 | protected function getParentEquipment($parentID) |
|
| 54 | } |
||
| 55 | } |
||
| 56 |