| @@ 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"; |
|
| @@ 155-163 (lines=9) @@ | ||
| 152 | */ |
|
| 153 | public function setVariables($variables, $overwrite = false) |
|
| 154 | { |
|
| 155 | if (!is_array($variables) && !$variables instanceof \Traversable) { |
|
| 156 | throw new \InvalidArgumentException( |
|
| 157 | sprintf( |
|
| 158 | '%s: expects an array, or Traversable argument; received "%s"', |
|
| 159 | __METHOD__, |
|
| 160 | (is_object($variables) ? get_class($variables) : gettype($variables)) |
|
| 161 | ) |
|
| 162 | ); |
|
| 163 | } |
|
| 164 | ||
| 165 | if ($overwrite) { |
|
| 166 | if (is_object($variables) && !$variables instanceof \ArrayAccess) { |
|
| @@ 80-90 (lines=11) @@ | ||
| 77 | ||
| 78 | public function addVariables($variables = array()) |
|
| 79 | { |
|
| 80 | if (!is_array($variables)) { |
|
| 81 | if (!$variables instanceof \Traversable) { |
|
| 82 | throw new \InvalidArgumentException( |
|
| 83 | sprintf( |
|
| 84 | 'Expect an array or an instance of \Traversable, but received %s', |
|
| 85 | is_object($variables) ? 'instance of ' . get_class($variables) : 'skalar' |
|
| 86 | ) |
|
| 87 | ); |
|
| 88 | } |
|
| 89 | $variables = \Zend\Stdlib\ArrayUtils::iteratorToArray($variables); |
|
| 90 | } |
|
| 91 | ||
| 92 | $this->variables = array_merge($this->variables, $variables); |
|
| 93 | return $this; |
|
| @@ 110-119 (lines=10) @@ | ||
| 107 | ||
| 108 | public function addCallbacks($callbacks = array()) |
|
| 109 | { |
|
| 110 | if (!is_array($callbacks)) { |
|
| 111 | if (!$callbacks instanceof \Traversable) { |
|
| 112 | throw new \InvalidArgumentException( |
|
| 113 | sprintf( |
|
| 114 | 'Expect an array or an instance of \Traversable, but received %s', |
|
| 115 | is_object($callbacks) ? 'instance of ' . get_class($callbacks) : 'skalar' |
|
| 116 | ) |
|
| 117 | ); |
|
| 118 | } |
|
| 119 | } |
|
| 120 | ||
| 121 | foreach ($callbacks as $name => $callback) { |
|
| 122 | $this->setCallback($name, $callback); |
|