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