| Total Complexity | 8 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | class Registry implements RegistryInterface |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @var DeviceInterface |
||
| 20 | */ |
||
| 21 | private $device; |
||
| 22 | /** |
||
| 23 | * @var array |
||
| 24 | */ |
||
| 25 | private $commandsRegistry = []; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * CommandRegistry constructor. |
||
| 29 | * @param DeviceInterface $device |
||
| 30 | */ |
||
| 31 | public function __construct(DeviceInterface $device) |
||
| 32 | { |
||
| 33 | $this->device = $device; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param CommandInterface $command |
||
| 38 | * @param TypeInterface $type |
||
| 39 | */ |
||
| 40 | public function setCommand(CommandInterface $command, TypeInterface $type): void |
||
| 41 | { |
||
| 42 | $this->commandsRegistry[$type->getName()] = $command; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param TypeInterface $type |
||
| 47 | */ |
||
| 48 | public function execute(TypeInterface $type): void |
||
| 52 | } |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @return DeviceInterface |
||
| 57 | */ |
||
| 58 | public function getDevice(): DeviceInterface |
||
| 59 | { |
||
| 60 | return $this->device; |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @param string|null $key |
||
| 65 | * @return array|mixed |
||
| 66 | */ |
||
| 67 | public function getCommandsRegistry(string $key = null) |
||
| 78 | } |
||
| 79 | } |
||
| 80 |