File indexing completed on 2024-12-22 05:36:43
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Gdata 0017 * @subpackage Analytics 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * @see Zend_Gdata_Entry 0025 */ 0026 // require_once 'Zend/Gdata/Entry.php'; 0027 0028 /** 0029 * @category Zend 0030 * @package Zend_Gdata 0031 * @subpackage Analytics 0032 */ 0033 class Zend_Gdata_Analytics_DataEntry extends Zend_Gdata_Entry 0034 { 0035 /** 0036 * @var array 0037 */ 0038 protected $_dimensions = array(); 0039 /** 0040 * @var array 0041 */ 0042 protected $_metrics = array(); 0043 0044 /** 0045 * @param DOMElement $element 0046 */ 0047 public function __construct($element = null) 0048 { 0049 $this->registerAllNamespaces(Zend_Gdata_Analytics::$namespaces); 0050 parent::__construct($element); 0051 } 0052 0053 /** 0054 * @param DOMElement $child 0055 * @return void 0056 */ 0057 protected function takeChildFromDOM($child) 0058 { 0059 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; 0060 switch ($absoluteNodeName) { 0061 case $this->lookupNamespace('analytics') . ':' . 'dimension'; 0062 $dimension = new Zend_Gdata_Analytics_Extension_Dimension(); 0063 $dimension->transferFromDOM($child); 0064 $this->_dimensions[] = $dimension; 0065 break; 0066 case $this->lookupNamespace('analytics') . ':' . 'metric'; 0067 $metric = new Zend_Gdata_Analytics_Extension_Metric(); 0068 $metric->transferFromDOM($child); 0069 $this->_metrics[] = $metric; 0070 break; 0071 default: 0072 parent::takeChildFromDOM($child); 0073 break; 0074 } 0075 } 0076 0077 /** 0078 * @param string $name 0079 * @return mixed 0080 */ 0081 public function getDimension($name) 0082 { 0083 foreach ($this->_dimensions as $dimension) { 0084 if ($dimension->getName() == $name) { 0085 return $dimension; 0086 } 0087 } 0088 return null; 0089 } 0090 0091 /** 0092 * @param string $name 0093 * @return mixed 0094 */ 0095 public function getMetric($name) 0096 { 0097 foreach ($this->_metrics as $metric) { 0098 if ($metric->getName() == $name) { 0099 return $metric; 0100 } 0101 } 0102 return null; 0103 } 0104 0105 /** 0106 * @param string $name 0107 * @return mixed 0108 */ 0109 public function getValue($name) 0110 { 0111 if (null !== ($metric = $this->getMetric($name))) { 0112 return $metric; 0113 } 0114 return $this->getDimension($name); 0115 } 0116 }