| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Tool
- * @subpackage Framework
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
- /**
- * @see Zend_Tool_Framework_Metadata_Interface
- */
- require_once 'Zend/Tool/Framework/Metadata/Interface.php';
- /**
- * @see Zend_Tool_Framework_Metadata_Attributable
- */
- require_once 'Zend/Tool/Framework/Metadata/Attributable.php';
- /**
- * @category Zend
- * @package Zend_Tool
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
- class Zend_Tool_Framework_Metadata_Basic
- implements Zend_Tool_Framework_Metadata_Interface, Zend_Tool_Framework_Metadata_Attributable
- {
- /**#@+
- * Search constants
- */
- const ATTRIBUTES_ALL = 'attributesAll';
- const ATTRIBUTES_NO_PARENT = 'attributesParent';
- /**#@-*/
- /**#@+
- * @var string
- */
- protected $_type = 'Basic';
- protected $_name = null;
- protected $_value = null;
- /**#@-*/
- /**
- * @var mixed
- */
- protected $_reference = null;
- /**
- * Constructor - allows for the setting of options
- *
- * @param array $options
- */
- public function __construct(Array $options = array())
- {
- if ($options) {
- $this->setOptions($options);
- }
- }
- /**
- * setOptions() - standard issue implementation, this will set any
- * options that are supported via a set method.
- *
- * @param array $options
- * @return Zend_Tool_Framework_Metadata_Basic
- */
- public function setOptions(Array $options)
- {
- foreach ($options as $optionName => $optionValue) {
- $setMethod = 'set' . $optionName;
- if (method_exists($this, $setMethod)) {
- $this->{$setMethod}($optionValue);
- }
- }
- return $this;
- }
- /**
- * getType()
- *
- * @return string
- */
- public function getType()
- {
- return $this->_type;
- }
- /**
- * setType()
- *
- * @param string $type
- * @return Zend_Tool_Framework_Metadata_Basic
- */
- public function setType($type)
- {
- $this->_type = $type;
- return $this;
- }
- /**
- * getName()
- *
- * @return string
- */
- public function getName()
- {
- return $this->_name;
- }
- /**
- * setName()
- *
- * @param string $name
- * @return Zend_Tool_Framework_Metadata_Basic
- */
- public function setName($name)
- {
- $this->_name = $name;
- return $this;
- }
- /**
- * getValue()
- *
- * @return mixed
- */
- public function getValue()
- {
- return $this->_value;
- }
- /**
- * setValue()
- *
- * @param unknown_type $Value
- * @return Zend_Tool_Framework_Metadata_Basic
- */
- public function setValue($value)
- {
- $this->_value = $value;
- return $this;
- }
- /**
- * setReference()
- *
- * @param mixed $reference
- * @return Zend_Tool_Framework_Metadata_Basic
- */
- public function setReference($reference)
- {
- $this->_reference = $reference;
- return $this;
- }
- /**
- * getReference()
- *
- * @return mixed
- */
- public function getReference()
- {
- return $this->_reference;
- }
- /**
- * getAttributes() - this will retrieve any attributes of this object that exist as properties
- * This is most useful for printing metadata.
- *
- * @param const $type
- * @return array
- */
- public function getAttributes($type = self::ATTRIBUTES_ALL, $stringRepresentationOfNonScalars = false)
- {
- $thisReflection = new ReflectionObject($this);
- $metadataPairValues = array();
- foreach (get_object_vars($this) as $varName => $varValue) {
- if ($type == self::ATTRIBUTES_NO_PARENT && ($thisReflection->getProperty($varName)->getDeclaringClass()->getName() == 'Zend_Tool_Framework_Metadata_Basic')) {
- continue;
- }
- if ($stringRepresentationOfNonScalars) {
- if (is_object($varValue)) {
- $varValue = '(object)';
- }
- if ($varValue === null) {
- $varValue = '(null)';
- }
- }
- $metadataPairValues[ltrim($varName, '_')] = $varValue;
- }
- return $metadataPairValues;
- }
- /**
- * __toString() - string representation of this object
- *
- * @return string
- */
- public function __toString()
- {
- return 'Type: ' . $this->_type . ', Name: ' . $this->_name . ', Value: ' . (is_array($this->_value) ? http_build_query($this->_value) : (string) $this->_value);
- }
- }
|