| @@ 37-47 (lines=11) @@ | ||
| 34 | ||
| 35 | public function addVariables($variables = array()) |
|
| 36 | { |
|
| 37 | if (!is_array($variables)) { |
|
| 38 | if (!$variables instanceof \Traversable) { |
|
| 39 | throw new \InvalidArgumentException( |
|
| 40 | sprintf( |
|
| 41 | 'Expect an array or an instance of \Traversable, but received %s', |
|
| 42 | is_object($variables) ? 'instance of ' . get_class($variables) : 'skalar' |
|
| 43 | ) |
|
| 44 | ); |
|
| 45 | } |
|
| 46 | $variables = \Zend\Stdlib\ArrayUtils::iteratorToArray($variables); |
|
| 47 | } |
|
| 48 | ||
| 49 | $this->variables = array_merge($this->variables, $variables); |
|
| 50 | return $this; |
|
| @@ 67-76 (lines=10) @@ | ||
| 64 | ||
| 65 | public function addCallbacks($callbacks = array()) |
|
| 66 | { |
|
| 67 | if (!is_array($callbacks)) { |
|
| 68 | if (!$callbacks instanceof \Traversable) { |
|
| 69 | throw new \InvalidArgumentException( |
|
| 70 | sprintf( |
|
| 71 | 'Expect an array or an instance of \Traversable, but received %s', |
|
| 72 | is_object($callbacks) ? 'instance of ' . get_class($callbacks) : 'skalar' |
|
| 73 | ) |
|
| 74 | ); |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| 78 | foreach ($this->callbacks as $name => $callback) { |
|
| 79 | $this->setCallback($name, $callback); |
|
| @@ 30-37 (lines=8) @@ | ||
| 27 | ||
| 28 | public function setOptions($options) |
|
| 29 | { |
|
| 30 | if (!is_array($options) && !$options instanceof \Traversable) { |
|
| 31 | throw new \InvalidArgumentException( |
|
| 32 | sprintf( |
|
| 33 | 'Expected $options to be an array or \Traversable, but received %s', |
|
| 34 | (is_object($options) ? 'instance of ' . get_class($options) : 'skalar') |
|
| 35 | ) |
|
| 36 | ); |
|
| 37 | } |
|
| 38 | ||
| 39 | foreach ($options as $key => $value) { |
|
| 40 | $method = "set$key"; |
|
| @@ 150-158 (lines=9) @@ | ||
| 147 | */ |
|
| 148 | public function setVariables($variables, $overwrite = false) |
|
| 149 | { |
|
| 150 | if (!is_array($variables) && !$variables instanceof \Traversable) { |
|
| 151 | throw new \InvalidArgumentException( |
|
| 152 | sprintf( |
|
| 153 | '%s: expects an array, or Traversable argument; received "%s"', |
|
| 154 | __METHOD__, |
|
| 155 | (is_object($variables) ? get_class($variables) : gettype($variables)) |
|
| 156 | ) |
|
| 157 | ); |
|
| 158 | } |
|
| 159 | ||
| 160 | if ($overwrite) { |
|
| 161 | if (is_object($variables) && !$variables instanceof \ArrayAccess) { |
|