| Total Complexity | 9 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 17 | class DeviceSpecification extends Specification |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * 必选服务 |
||
| 21 | * |
||
| 22 | * @var |
||
| 23 | */ |
||
| 24 | protected $requiredServices; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * 可选服务 |
||
| 28 | * |
||
| 29 | * @var |
||
| 30 | */ |
||
| 31 | protected $optionalServices; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @throws \MiotApi\Exception\SpecificationErrorException |
||
| 35 | */ |
||
| 36 | public function init() |
||
| 37 | { |
||
| 38 | parent::init(); |
||
| 39 | |||
| 40 | if ($this->has('required-services')) { |
||
|
|
|||
| 41 | $requiredServices = $this->__get('required-services'); |
||
| 42 | if (!empty($requiredServices)) { |
||
| 43 | foreach ($requiredServices as $index => $service) { |
||
| 44 | $this->requiredServices[] = new ServiceSpecification($service); |
||
| 45 | } |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | if ($this->has('required-services')) { |
||
| 50 | $optionalServices = $this->__get('optional-services'); |
||
| 51 | if (!empty($optionalServices)) { |
||
| 52 | foreach ($optionalServices as $index => $service) { |
||
| 53 | $this->optionalServices[] = new ServiceSpecification($service); |
||
| 54 | } |
||
| 55 | } |
||
| 56 | } |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * 获取 必选服务 |
||
| 61 | * |
||
| 62 | * @return mixed |
||
| 63 | */ |
||
| 64 | public function getRequiredServices() |
||
| 65 | { |
||
| 66 | return $this->requiredServices; |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * 获取 可选服务 |
||
| 71 | * |
||
| 72 | * @return mixed |
||
| 73 | */ |
||
| 74 | public function getOptionalServices() |
||
| 77 | } |
||
| 78 | } |
||
| 79 |