@@ 29-44 (lines=16) @@ | ||
26 | * |
|
27 | * @param mixed $elements |
|
28 | */ |
|
29 | public function addElements($elements) |
|
30 | { |
|
31 | if (!is_array($elements) && !$elements instanceof \Traversable) { |
|
32 | throw new \InvalidArgumentException(sprintf('Argument is not traversable: %s', $elements)); |
|
33 | } |
|
34 | ||
35 | $elements = is_array($elements) ? $elements : iterator_to_array($elements); |
|
36 | ||
37 | foreach ($elements as $element) { |
|
38 | if (!is_a($element, ElementInterface::class)) { |
|
39 | throw new \InvalidArgumentException('Provider expects ElementInterface[]'); |
|
40 | } |
|
41 | } |
|
42 | ||
43 | $this->specElements = array_merge($this->specElements, $elements); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @param Upgrade $context |
@@ 57-72 (lines=16) @@ | ||
54 | * |
|
55 | * @param mixed $providers |
|
56 | */ |
|
57 | public function addProviders($providers) |
|
58 | { |
|
59 | if (!is_array($providers) && !$providers instanceof \Traversable) { |
|
60 | throw new \InvalidArgumentException(sprintf('Argument is not traversable: %s', $providers)); |
|
61 | } |
|
62 | ||
63 | $providers = is_array($providers) ? $providers : iterator_to_array($providers); |
|
64 | ||
65 | foreach ($providers as $provider) { |
|
66 | if (!is_a($provider, ProviderInterface::class)) { |
|
67 | throw new \InvalidArgumentException('ProviderChain expects ProviderInterface[]'); |
|
68 | } |
|
69 | } |
|
70 | ||
71 | $this->providers = array_merge($this->providers, $providers); |
|
72 | } |
|
73 | } |
|
74 |