| 1 | <?php |
||
| 24 | trait ArgumentChannelTrait |
||
| 25 | { |
||
| 26 | protected string $channel; |
||
|
|
|||
| 27 | protected CentrifugoChecker $centrifugoChecker; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param InputInterface $input |
||
| 31 | * |
||
| 32 | * @throws InvalidArgumentException |
||
| 33 | */ |
||
| 34 | protected function initializeChannelArgument(InputInterface $input): void |
||
| 35 | { |
||
| 36 | $channel = $input->getArgument('channel'); |
||
| 37 | |||
| 38 | if (!\is_string($channel)) { |
||
| 39 | throw new InvalidArgumentException('Argument "channel" is not a string.'); |
||
| 40 | } |
||
| 41 | |||
| 42 | try { |
||
| 43 | $this->centrifugoChecker->assertValidChannelName($channel); |
||
| 44 | $this->channel = $channel; |
||
| 45 | } catch (\Throwable $e) { |
||
| 46 | throw new InvalidArgumentException($e->getMessage()); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | } |
||
| 50 |