composer package updates
[openemr.git] / vendor / zendframework / zend-server / src / Method / Parameter.php
blob5e46327cb666026f676bdca422128f1ffbd11301
1 <?php
2 /**
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
6 */
8 namespace Zend\Server\Method;
10 /**
11 * Method parameter metadata
13 class Parameter
15 /**
16 * Default parameter value
18 * @var mixed
20 protected $defaultValue;
22 /**
23 * Parameter description
25 * @var string
27 protected $description = '';
29 /**
30 * Parameter variable name
32 * @var string
34 protected $name;
36 /**
37 * Is parameter optional?
39 * @var bool
41 protected $optional = false;
43 /**
44 * Parameter type
46 * @var string
48 protected $type = 'mixed';
50 /**
51 * Constructor
53 * @param null|array $options
55 public function __construct($options = null)
57 if (is_array($options)) {
58 $this->setOptions($options);
62 /**
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);
76 return $this;
79 /**
80 * Set default value
82 * @param mixed $defaultValue
83 * @return \Zend\Server\Method\Parameter
85 public function setDefaultValue($defaultValue)
87 $this->defaultValue = $defaultValue;
88 return $this;
91 /**
92 * Retrieve default value
94 * @return mixed
96 public function getDefaultValue()
98 return $this->defaultValue;
102 * Set description
104 * @param string $description
105 * @return \Zend\Server\Method\Parameter
107 public function setDescription($description)
109 $this->description = (string) $description;
110 return $this;
114 * Retrieve description
116 * @return string
118 public function getDescription()
120 return $this->description;
124 * Set name
126 * @param string $name
127 * @return \Zend\Server\Method\Parameter
129 public function setName($name)
131 $this->name = (string) $name;
132 return $this;
136 * Retrieve name
138 * @return string
140 public function getName()
142 return $this->name;
146 * Set optional flag
148 * @param bool $flag
149 * @return \Zend\Server\Method\Parameter
151 public function setOptional($flag)
153 $this->optional = (bool) $flag;
154 return $this;
158 * Is the parameter optional?
160 * @return bool
162 public function isOptional()
164 return $this->optional;
168 * Set parameter type
170 * @param string $type
171 * @return \Zend\Server\Method\Parameter
173 public function setType($type)
175 $this->type = (string) $type;
176 return $this;
180 * Retrieve parameter type
182 * @return string
184 public function getType()
186 return $this->type;
190 * Cast to array
192 * @return array
194 public function toArray()
196 return [
197 'type' => $this->getType(),
198 'name' => $this->getName(),
199 'optional' => $this->isOptional(),
200 'defaultValue' => $this->getDefaultValue(),
201 'description' => $this->getDescription(),