source: trunk/library/Zend/Ldap/Node/Schema/Item.php @ 5146

Revision 5146, 3.7 KB checked in by wmerlotto, 12 years ago (diff)

Ticket #2305 - Enviando alteracoes, desenvolvidas internamente na Prognus. Library: adicionando arquivos.

Line 
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 license@zend.com so we can send you a copy immediately.
14 *
15 * @category   Zend
16 * @package    Zend_Ldap
17 * @subpackage Schema
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: Item.php 20096 2010-01-06 02:05:09Z bkarwin $
21 */
22
23/**
24 * Zend_Ldap_Node_Schema_Item provides a base implementation for managing schema
25 * items like objectClass and attribute.
26 *
27 * @category   Zend
28 * @package    Zend_Ldap
29 * @subpackage Schema
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 */
33abstract class Zend_Ldap_Node_Schema_Item implements ArrayAccess, Countable
34{
35    /**
36     * The underlying data
37     *
38     * @var array
39     */
40    protected $_data;
41
42    /**
43     * Constructor.
44     *
45     * @param array $data
46     */
47    public function __construct(array $data)
48    {
49        $this->setData($data);
50    }
51
52    /**
53     * Sets the data
54     *
55     * @param  array $data
56     * @return Zend_Ldap_Node_Schema_Item Provides a fluid interface
57     */
58    public function setData(array $data)
59    {
60        $this->_data = $data;
61        return $this;
62    }
63
64    /**
65     * Gets the data
66     *
67     * @return array
68     */
69    public function getData()
70    {
71        return $this->_data;
72    }
73
74    /**
75     * Gets a specific attribute from this item
76     *
77     * @param  string $name
78     * @return mixed
79     */
80    public function __get($name)
81    {
82        if (array_key_exists($name, $this->_data)) {
83            return $this->_data[$name];
84        } else {
85            return null;
86        }
87    }
88
89    /**
90     * Checks whether a specific attribute exists.
91     *
92     * @param  string $name
93     * @return boolean
94     */
95    public function __isset($name)
96    {
97        return (array_key_exists($name, $this->_data));
98    }
99
100    /**
101     * Always throws BadMethodCallException
102     * Implements ArrayAccess.
103     *
104     * This method is needed for a full implementation of ArrayAccess
105     *
106     * @param  string $name
107     * @param  mixed $value
108     * @return null
109     * @throws BadMethodCallException
110     */
111    public function offsetSet($name, $value)
112    {
113        throw new BadMethodCallException();
114    }
115
116    /**
117     * Gets a specific attribute from this item
118     *
119     * @param  string $name
120     * @return mixed
121     */
122    public function offsetGet($name)
123    {
124        return $this->__get($name);
125    }
126
127    /**
128     * Always throws BadMethodCallException
129     * Implements ArrayAccess.
130     *
131     * This method is needed for a full implementation of ArrayAccess
132     *
133     * @param  string $name
134     * @return null
135     * @throws BadMethodCallException
136     */
137    public function offsetUnset($name)
138    {
139        throw new BadMethodCallException();
140    }
141
142    /**
143     * Checks whether a specific attribute exists.
144     *
145     * @param  string $name
146     * @return boolean
147     */
148    public function offsetExists($name)
149    {
150        return $this->__isset($name);
151    }
152
153    /**
154     * Returns the number of attributes.
155     * Implements Countable
156     *
157     * @return int
158     */
159    public function count()
160    {
161        return count($this->_data);
162    }
163}
Note: See TracBrowser for help on using the repository browser.