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 license@zend.com so we can send you a copy immediately.
16
* @package Zend_Service
17
* @subpackage StrikeIron
18
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
19
* @license http://framework.zend.com/license/new-bsd New BSD License
20
* @version $Id: Decorator.php 8064 2008-02-16 10:58:39Z thomas $
24
* Decorates a StrikeIron response object returned by the SOAP extension
25
* to provide more a PHP-like interface.
28
* @package Zend_Service
29
* @subpackage StrikeIron
30
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
31
* @license http://framework.zend.com/license/new-bsd New BSD License
33
class Zend_Service_StrikeIron_Decorator
36
* Name of the decorated object
39
protected $_name = null;
45
protected $_object = null;
50
* @param object $object Object to decorate
51
* @param null|string $name Name of the object
53
public function __construct($object, $name = null)
55
$this->_object = $object;
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.
65
* @param string $property Property name to retrieve
66
* @return mixed Value of property or NULL
68
public function __get($property)
72
if (! isset($this->_object->$property)) {
73
$property = $this->_inflect($property);
76
if (isset($this->_object->$property)) {
77
$result = $this->_object->$property;
78
$result = $this->_decorate($result);
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.
88
* @param string $method Name of method called
89
* @param array $args Arguments for method
91
public function __call($method, $args)
93
return call_user_func_array(array($this->_object, $method), $args);
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".
101
* @param string $property Property name to inflect
102
* @return string Inflected property name
104
protected function _inflect($property)
106
return ucfirst($property);
110
* Decorate a value returned by the result object. The default
111
* implementation here only decorates child objects.
113
* @param mixed $result Value to decorate
114
* @return mixed Decorated result
116
protected function _decorate($result)
118
if (is_object($result)) {
119
$result = new self($result);
125
* Return the object being decorated
129
public function getDecoratedObject()
131
return $this->_object;
135
* Return the name of the object being decorated
137
* @return null|string
139
public function getDecoratedObjectName()