| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * File containing the ezcGraphArrayDataSet class 4 * 5 * @package Graph 6 * @version 1.5 7 * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. 8 * @license http://ez.no/licenses/new_bsd New BSD License 9 */ 10 /** 11 * Dataset class which receives arrays and use them as a base for datasets. 12 * 13 * @version 1.5 14 * @package Graph 15 * @mainclass 16 */ 17 class ezcGraphArrayDataSet extends ezcGraphDataSet 18 { 19 /** 20 * Constructor 21 * 22 * @param array|Iterator $data Array or Iterator containing the data 23 * @return void 24 */ 25 public function __construct( $data ) 26 { 27 $this->createFromArray( $data ); 28 parent::__construct(); 29 } 30 31 /** 32 * setData 33 * 34 * Can handle data provided through an array or iterator. 35 * 36 * @param array|Iterator $data 37 * @access public 38 * @return void 39 */ 40 protected function createFromArray( $data = array() ) 41 { 42 if ( !is_array( $data ) && 43 !( $data instanceof Traversable ) ) 44 { 45 throw new ezcGraphInvalidArrayDataSourceException( $data ); 46 } 47 48 $this->data = array(); 49 foreach ( $data as $key => $value ) 50 { 51 $this->data[$key] = $value; 52 } 53 54 if ( !count( $this->data ) ) 55 { 56 throw new ezcGraphInvalidDataException( 'Data sets should contain some values.' ); 57 } 58 } 59 60 /** 61 * Returns the number of elements in this dataset 62 * 63 * @return int 64 */ 65 public function count() 66 { 67 return count( $this->data ); 68 } 69 } 70 71 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jul 28 15:48:31 2011 | Cross-referenced by PHPXref 0.7 |