From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- library/vendor/Zend/Server/Method/Prototype.php | 207 ++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 library/vendor/Zend/Server/Method/Prototype.php (limited to 'library/vendor/Zend/Server/Method/Prototype.php') diff --git a/library/vendor/Zend/Server/Method/Prototype.php b/library/vendor/Zend/Server/Method/Prototype.php new file mode 100644 index 0000000..33c5a14 --- /dev/null +++ b/library/vendor/Zend/Server/Method/Prototype.php @@ -0,0 +1,207 @@ +setOptions($options); + } + } + + /** + * Set return value + * + * @param string $returnType + * @return Zend_Server_Method_Prototype + */ + public function setReturnType($returnType) + { + $this->_returnType = $returnType; + return $this; + } + + /** + * Retrieve return type + * + * @return string + */ + public function getReturnType() + { + return $this->_returnType; + } + + /** + * Add a parameter + * + * @param string $parameter + * @return Zend_Server_Method_Prototype + */ + public function addParameter($parameter) + { + if ($parameter instanceof Zend_Server_Method_Parameter) { + $this->_parameters[] = $parameter; + if (null !== ($name = $parameter->getName())) { + $this->_parameterNameMap[$name] = count($this->_parameters) - 1; + } + } else { + $parameter = new Zend_Server_Method_Parameter(array( + 'type' => (string) $parameter, + )); + $this->_parameters[] = $parameter; + } + return $this; + } + + /** + * Add parameters + * + * @param array $parameter + * @return Zend_Server_Method_Prototype + */ + public function addParameters(array $parameters) + { + foreach ($parameters as $parameter) { + $this->addParameter($parameter); + } + return $this; + } + + /** + * Set parameters + * + * @param array $parameters + * @return Zend_Server_Method_Prototype + */ + public function setParameters(array $parameters) + { + $this->_parameters = array(); + $this->_parameterNameMap = array(); + $this->addParameters($parameters); + return $this; + } + + /** + * Retrieve parameters as list of types + * + * @return array + */ + public function getParameters() + { + $types = array(); + foreach ($this->_parameters as $parameter) { + $types[] = $parameter->getType(); + } + return $types; + } + + /** + * Get parameter objects + * + * @return array + */ + public function getParameterObjects() + { + return $this->_parameters; + } + + /** + * Retrieve a single parameter by name or index + * + * @param string|int $index + * @return null|Zend_Server_Method_Parameter + */ + public function getParameter($index) + { + if (!is_string($index) && !is_numeric($index)) { + return null; + } + if (array_key_exists($index, $this->_parameterNameMap)) { + $index = $this->_parameterNameMap[$index]; + } + if (array_key_exists($index, $this->_parameters)) { + return $this->_parameters[$index]; + } + return null; + } + + /** + * Set object state from array + * + * @param array $options + * @return Zend_Server_Method_Prototype + */ + public function setOptions(array $options) + { + foreach ($options as $key => $value) { + $method = 'set' . ucfirst($key); + if (method_exists($this, $method)) { + $this->$method($value); + } + } + return $this; + } + + /** + * Serialize to array + * + * @return array + */ + public function toArray() + { + return array( + 'returnType' => $this->getReturnType(), + 'parameters' => $this->getParameters(), + ); + } +} -- cgit v1.2.3