1 | <?php |
||
8 | class Hash extends GuzzleCollection implements Encodable |
||
9 | { |
||
10 | protected $required = []; |
||
11 | protected $defaults = []; |
||
12 | protected $optional = []; |
||
13 | |||
14 | /** |
||
15 | * @param array $data |
||
16 | */ |
||
17 | 75 | public function __construct($data = []) |
|
18 | { |
||
19 | 75 | $resolver = new OptionsResolver(); |
|
20 | 75 | $this->setDefaultOptions($resolver); |
|
21 | 75 | parent::__construct($resolver->resolve($data)); |
|
22 | 74 | } |
|
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | 7 | public static function fromConfig(array $config = [], array $defaults = [], array $required = []) |
|
28 | { |
||
29 | 7 | if (!empty($defaults) || !empty($required)) { |
|
30 | 2 | throw new LogicException('Setting options on fromConfig is not allowed.'); |
|
31 | } |
||
32 | |||
33 | 5 | return new static($config); |
|
34 | } |
||
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | 3 | public function __toString() |
|
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | 4 | public function jsonSerialize() |
|
51 | |||
52 | /** |
||
53 | * @param OptionsResolver $resolver |
||
54 | */ |
||
55 | 75 | protected function setDefaultOptions(OptionsResolver $resolver) |
|
61 | } |
||
62 |