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/Callback.php | 204 +++++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 library/vendor/Zend/Server/Method/Callback.php (limited to 'library/vendor/Zend/Server/Method/Callback.php') diff --git a/library/vendor/Zend/Server/Method/Callback.php b/library/vendor/Zend/Server/Method/Callback.php new file mode 100644 index 0000000..3f81197 --- /dev/null +++ b/library/vendor/Zend/Server/Method/Callback.php @@ -0,0 +1,204 @@ +setOptions($options); + } + } + + /** + * Set object state from array of options + * + * @param array $options + * @return Zend_Server_Method_Callback + */ + public function setOptions(array $options) + { + foreach ($options as $key => $value) { + $method = 'set' . ucfirst($key); + if (method_exists($this, $method)) { + $this->$method($value); + } + } + return $this; + } + + /** + * Set callback class + * + * @param string $class + * @return Zend_Server_Method_Callback + */ + public function setClass($class) + { + if (is_object($class)) { + $class = get_class($class); + } + $this->_class = $class; + return $this; + } + + /** + * Get callback class + * + * @return string|null + */ + public function getClass() + { + return $this->_class; + } + + /** + * Set callback function + * + * @param string $function + * @return Zend_Server_Method_Callback + */ + public function setFunction($function) + { + $this->_function = (string) $function; + $this->setType('function'); + return $this; + } + + /** + * Get callback function + * + * @return null|string + */ + public function getFunction() + { + return $this->_function; + } + + /** + * Set callback class method + * + * @param string $method + * @return Zend_Server_Method_Callback + */ + public function setMethod($method) + { + $this->_method = $method; + return $this; + } + + /** + * Get callback class method + * + * @return null|string + */ + public function getMethod() + { + return $this->_method; + } + + /** + * Set callback type + * + * @param string $type + * @return Zend_Server_Method_Callback + * @throws Zend_Server_Exception + */ + public function setType($type) + { + if (!in_array($type, $this->_types)) { + throw new Zend_Server_Exception('Invalid method callback type passed to ' . __CLASS__ . '::' . __METHOD__); + } + $this->_type = $type; + return $this; + } + + /** + * Get callback type + * + * @return string + */ + public function getType() + { + return $this->_type; + } + + /** + * Cast callback to array + * + * @return array + */ + public function toArray() + { + $type = $this->getType(); + $array = array( + 'type' => $type, + ); + if ('function' == $type) { + $array['function'] = $this->getFunction(); + } else { + $array['class'] = $this->getClass(); + $array['method'] = $this->getMethod(); + } + return $array; + } +} -- cgit v1.2.3