[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/include/Zend/Gdata/Analytics/ -> DataEntry.php (source)

   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 [email protected] so we can send you a copy immediately.
  14   *
  15   * @category   Zend
  16   * @package    Zend_Gdata
  17   * @subpackage Analytics
  18   * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  20   * @version    $Id$
  21   */
  22  
  23  /**
  24   * @see Zend_Gdata_Entry
  25   */
  26  require_once  'Zend/Gdata/Entry.php';
  27  
  28  /**
  29   * @category   Zend
  30   * @package    Zend_Gdata
  31   * @subpackage Analytics
  32   */
  33  class Zend_Gdata_Analytics_DataEntry extends Zend_Gdata_Entry
  34  {
  35      /**
  36       * @var array
  37       */
  38      protected $_dimensions = array();
  39      /**
  40       * @var array
  41       */
  42      protected $_metrics = array();
  43  
  44      /**
  45       * @param DOMElement $element
  46       */
  47      public function __construct($element = null)
  48      {
  49          $this->registerAllNamespaces(Zend_Gdata_Analytics::$namespaces);
  50          parent::__construct($element);
  51      }
  52  
  53      /**
  54       * @param DOMElement $child
  55       * @return void
  56       */
  57      protected function takeChildFromDOM($child)
  58      {
  59          $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  60          switch ($absoluteNodeName) {
  61              case $this->lookupNamespace('analytics') . ':' . 'dimension';
  62                  $dimension = new Zend_Gdata_Analytics_Extension_Dimension();
  63                  $dimension->transferFromDOM($child);
  64                  $this->_dimensions[] = $dimension;
  65                  break;
  66              case $this->lookupNamespace('analytics') . ':' . 'metric';
  67                  $metric = new Zend_Gdata_Analytics_Extension_Metric();
  68                  $metric->transferFromDOM($child);
  69                  $this->_metrics[] = $metric;
  70                  break;
  71              default:
  72                  parent::takeChildFromDOM($child);
  73                  break;
  74          }
  75      }
  76  
  77      /**
  78       * @param string $name 
  79       * @return mixed
  80       */
  81      public function getDimension($name)
  82      {
  83          foreach ($this->_dimensions as $dimension) {
  84              if ($dimension->getName() == $name) {
  85                  return $dimension;
  86              }
  87          }
  88          return null;
  89      }
  90      
  91      /** 
  92       * @param string $name 
  93       * @return mixed
  94       */
  95      public function getMetric($name)
  96      {
  97          foreach ($this->_metrics as $metric) {
  98              if ($metric->getName() == $name) {
  99                  return $metric;
 100              }
 101          }
 102          return null;
 103      }
 104      
 105      /**
 106       * @param string $name 
 107       * @return mixed
 108       */
 109      public function getValue($name)
 110      {
 111          if (null !== ($metric = $this->getMetric($name))) {
 112              return $metric;
 113          }
 114          return $this->getDimension($name);
 115      }
 116  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1