3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
17 * @param array|Traversable $options
20 public static function getInstance($options = [])
22 if (! is_array($options) && ! $options instanceof Traversable
) {
23 throw new Exception\
InvalidArgumentException(sprintf(
24 '"%s" expects an array or Traversable; received "%s"',
26 (is_object($options) ?
get_class($options) : gettype($options))
30 $message = new Message();
32 foreach ($options as $key => $value) {
33 $setter = self
::getSetterMethod($key);
34 if (method_exists($message, $setter)) {
35 $message->{$setter}($value);
43 * Generate a setter method name based on a provided key.
48 private static function getSetterMethod($key)