| 1 | <?php |
||
| 9 | class Packet extends Event implements Encodable |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @param array $options |
||
| 13 | */ |
||
| 14 | 1 | public function __construct(array $options = []) |
|
| 15 | { |
||
| 16 | 1 | $resolver = new OptionsResolver(); |
|
| 17 | 1 | $this->setDefaultOptions($resolver); |
|
| 18 | |||
| 19 | 1 | parent::__construct($resolver->resolve($options)); |
|
| 20 | 1 | } |
|
| 21 | |||
| 22 | /** |
||
| 23 | * @param OptionsResolver $resolver |
||
| 24 | */ |
||
| 25 | 1 | protected function setDefaultOptions(OptionsResolver $resolver) |
|
| 26 | { |
||
| 27 | 1 | $resolver->setRequired(['command']); |
|
| 28 | 1 | $resolver->setDefaults(['output' => null]); |
|
| 29 | |||
| 30 | 1 | $resolver->setTypesAllowed([ |
|
| 31 | 1 | 'command' => '\Crummy\Phlack\WebHook\CommandInterface', |
|
| 32 | 1 | 'output' => ['\Crummy\Phlack\WebHook\Reply\Reply', 'null'], |
|
| 33 | 1 | ]); |
|
| 34 | 1 | } |
|
| 35 | |||
| 36 | /** |
||
| 37 | * {@inheritdoc} |
||
| 38 | */ |
||
| 39 | public function jsonSerialize() |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @return string |
||
| 46 | */ |
||
| 47 | public function __toString() |
||
| 51 | } |
||
| 52 |