3 * @see https://github.com/zendframework/zend-server for the canonical source repository
4 * @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (https://www.zend.com)
5 * @license https://github.com/zendframework/zend-server/blob/master/LICENSE.md New BSD License
8 namespace Zend\Server\Method
;
11 * Method parameter metadata
16 * Default parameter value
20 protected $defaultValue;
23 * Parameter description
27 protected $description = '';
30 * Parameter variable name
37 * Is parameter optional?
41 protected $optional = false;
48 protected $type = 'mixed';
53 * @param null|array $options
55 public function __construct($options = null)
57 if (is_array($options)) {
58 $this->setOptions($options);
63 * Set object state from array of options
65 * @param array $options
66 * @return \Zend\Server\Method\Parameter
68 public function setOptions(array $options)
70 foreach ($options as $key => $value) {
71 $method = 'set' . ucfirst($key);
72 if (method_exists($this, $method)) {
73 $this->$method($value);
82 * @param mixed $defaultValue
83 * @return \Zend\Server\Method\Parameter
85 public function setDefaultValue($defaultValue)
87 $this->defaultValue
= $defaultValue;
92 * Retrieve default value
96 public function getDefaultValue()
98 return $this->defaultValue
;
104 * @param string $description
105 * @return \Zend\Server\Method\Parameter
107 public function setDescription($description)
109 $this->description
= (string) $description;
114 * Retrieve description
118 public function getDescription()
120 return $this->description
;
126 * @param string $name
127 * @return \Zend\Server\Method\Parameter
129 public function setName($name)
131 $this->name
= (string) $name;
140 public function getName()
149 * @return \Zend\Server\Method\Parameter
151 public function setOptional($flag)
153 $this->optional
= (bool) $flag;
158 * Is the parameter optional?
162 public function isOptional()
164 return $this->optional
;
170 * @param string $type
171 * @return \Zend\Server\Method\Parameter
173 public function setType($type)
175 $this->type
= (string) $type;
180 * Retrieve parameter type
184 public function getType()
194 public function toArray()
197 'type' => $this->getType(),
198 'name' => $this->getName(),
199 'optional' => $this->isOptional(),
200 'defaultValue' => $this->getDefaultValue(),
201 'description' => $this->getDescription(),