1: <?php
2: /**
3: * The base class representing Kolab object attributes.
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: * The base class representing Kolab object attributes.
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: abstract class Horde_Kolab_Server_Object_Attribute_Base
29: implements Horde_Kolab_Server_Object_Attribute_Interface
30: {
31: /**
32: * The attribute name.
33: *
34: * @param string
35: */
36: protected $name;
37:
38: /**
39: * The internal attribute adapter.
40: *
41: * @param Horde_Kolab_Server_Structure_Attribute_Interface
42: */
43: protected $attribute;
44:
45: /**
46: * Constructor
47: *
48: * @param Horde_Kolab_Server_Structure_Attribute_Interface $attribute The internal attribute adapter.
49: * @param string $name The name of this attribute.
50: */
51: public function __construct(
52: Horde_Kolab_Server_Structure_Attribute_Interface $attribute,
53: $name
54: ) {
55: $this->attribute = $attribute;
56: $this->name = $name;
57: }
58:
59: /**
60: * Return the internal attribute adapter.
61: *
62: * @return Horde_Kolab_Server_Structure_Attribute_Interface The internal
63: * attribute.
64: */
65: public function getAttribute()
66: {
67: return $this->attribute;
68: }
69:
70: /**
71: * Return the name of this attribute.
72: *
73: * @return string The name of this attribute.
74: */
75: public function getName()
76: {
77: return $this->name;
78: }
79:
80: /**
81: * Return if this attribute is undefined in the given data array.
82: *
83: * @param array $changes The data array to test.
84: *
85: * @return string The name of this object.
86: */
87: public function isEmpty(array $changes)
88: {
89: if ((!in_array($this->name, array_keys($changes))
90: || $changes[$this->name] === null
91: || $changes[$this->name] === ''
92: || $changes[$this->name] === array())
93: ) {
94: return true;
95: }
96: return false;
97: }
98: }