1: <?php
2: /**
3: * A base class for attribute decorators.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_Server
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Kolab_Server
12: */
13:
14: /**
15: * A base class for attribute decorators.
16: *
17: * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you
20: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
21: *
22: * @category Kolab
23: * @package Kolab_Server
24: * @author Gunnar Wrobel <wrobel@pardus.de>
25: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
26: * @link http://pear.horde.org/index.php?package=Kolab_Server
27: */
28: class Horde_Kolab_Server_Object_Attribute_Decorator
29: implements Horde_Kolab_Server_Object_Attribute_Interface
30: {
31: /**
32: * The decorated attribute.
33: *
34: * @param Horde_Kolab_Server_Object_Attribute
35: */
36: protected $_attribute;
37:
38: /**
39: * Constructor
40: *
41: * @param Horde_Kolab_Server_Object_Attribute $attribute The decorated
42: * attribute.
43: */
44: public function __construct(
45: Horde_Kolab_Server_Object_Attribute_Interface $attribute
46: ) {
47: $this->_attribute = $attribute;
48: }
49:
50: /**
51: * Return the value of this attribute.
52: *
53: * @return array The value(s) of this attribute.
54: */
55: public function value()
56: {
57: return $this->_attribute->value();
58: }
59:
60: /**
61: * Return the new internal state for this attribute.
62: *
63: * @param array $changes The object data that should be updated.
64: *
65: * @return array The resulting internal state.
66: *
67: * @throws Horde_Kolab_Server_Exception If storing the value failed.
68: */
69: public function update(array $changes)
70: {
71: return $this->_attribute->update($changes);
72: }
73:
74: /**
75: * Return the internal attribute adapter.
76: *
77: * @return Horde_Kolab_Server_Structure_Attribute_Interface The internal
78: */
79: public function getAttribute()
80: {
81: return $this->_attribute->getAttribute();
82: }
83:
84: /**
85: * Return the name of this attribute.
86: *
87: * @return string The name of this attribute.
88: */
89: public function getName()
90: {
91: return $this->_attribute->getName();
92: }
93:
94: /**
95: * Return if this attribute is undefined in the given data array.
96: *
97: * @param array $changes The data array to test.
98: *
99: * @return string The name of this object.
100: */
101: public function isEmpty(array $changes)
102: {
103: return $this->_attribute->isEmpty($changes);
104: }
105: }