| @@ 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"; |
|