[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Zend Framework 4 * 5 * LICENSE 6 * 7 * This source file is subject to the new BSD license that is bundled 8 * with this package in the file LICENSE.txt. 9 * It is also available through the world-wide-web at this URL: 10 * http://framework.zend.com/license/new-bsd 11 * If you did not receive a copy of the license and are unable to 12 * obtain it through the world-wide-web, please send an email 13 * to [email protected] so we can send you a copy immediately. 14 * 15 * @category Zend 16 * @package Zend_Service 17 * @subpackage StrikeIron 18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 19 * @license http://framework.zend.com/license/new-bsd New BSD License 20 * @version $Id$ 21 */ 22 23 /** 24 * Decorates a StrikeIron response object returned by the SOAP extension 25 * to provide more a PHP-like interface. 26 * 27 * @category Zend 28 * @package Zend_Service 29 * @subpackage StrikeIron 30 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 31 * @license http://framework.zend.com/license/new-bsd New BSD License 32 */ 33 class Zend_Service_StrikeIron_Decorator 34 { 35 /** 36 * Name of the decorated object 37 * @var null|string 38 */ 39 protected $_name = null; 40 41 /** 42 * Object to decorate 43 * @var object 44 */ 45 protected $_object = null; 46 47 /** 48 * Class constructor 49 * 50 * @param object $object Object to decorate 51 * @param null|string $name Name of the object 52 */ 53 public function __construct($object, $name = null) 54 { 55 $this->_object = $object; 56 $this->_name = $name; 57 } 58 59 /** 60 * Proxy property access to the decorated object, inflecting 61 * the property name and decorating any child objects returned. 62 * If the property is not found in the decorated object, return 63 * NULL as a convenience feature to avoid notices. 64 * 65 * @param string $property Property name to retrieve 66 * @return mixed Value of property or NULL 67 */ 68 public function __get($property) 69 { 70 $result = null; 71 72 if (! isset($this->_object->$property)) { 73 $property = $this->_inflect($property); 74 } 75 76 if (isset($this->_object->$property)) { 77 $result = $this->_object->$property; 78 $result = $this->_decorate($result); 79 } 80 return $result; 81 } 82 83 /** 84 * Proxy method calls to the decorated object. This will only 85 * be used when the SOAPClient returns a custom PHP object via 86 * its classmap option so no inflection is done. 87 * 88 * @param string $method Name of method called 89 * @param array $args Arguments for method 90 */ 91 public function __call($method, $args) 92 { 93 return call_user_func_array(array($this->_object, $method), $args); 94 } 95 96 /** 97 * Inflect a property name from PHP-style to the result object's 98 * style. The default implementation here only inflects the case 99 * of the first letter, e.g. from "fooBar" to "FooBar". 100 * 101 * @param string $property Property name to inflect 102 * @return string Inflected property name 103 */ 104 protected function _inflect($property) 105 { 106 return ucfirst($property); 107 } 108 109 /** 110 * Decorate a value returned by the result object. The default 111 * implementation here only decorates child objects. 112 * 113 * @param mixed $result Value to decorate 114 * @return mixed Decorated result 115 */ 116 protected function _decorate($result) 117 { 118 if (is_object($result)) { 119 $result = new self($result); 120 } 121 return $result; 122 } 123 124 /** 125 * Return the object being decorated 126 * 127 * @return object 128 */ 129 public function getDecoratedObject() 130 { 131 return $this->_object; 132 } 133 134 /** 135 * Return the name of the object being decorated 136 * 137 * @return null|string 138 */ 139 public function getDecoratedObjectName() 140 { 141 return $this->_name; 142 } 143 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |