File_IMC
[ class tree: File_IMC ] [ index: File_IMC ] [ all elements ]

Source for file Events.php

Documentation is available at Events.php

  1. <?php
  2. /*
  3.  * +----------------------------------------------------------------------+
  4.  * | Copyright (c) 1997-2008 The PHP Group                                |
  5.  * +----------------------------------------------------------------------+
  6.  * | All rights reserved.                                                 |
  7.  * |                                                                      |
  8.  * | Redistribution and use in source and binary forms, with or without   |
  9.  * | modification, are permitted provided that the following conditions   |
  10.  * | are met:                                                             |
  11.  * |                                                                      |
  12.  * | - Redistributions of source code must retain the above copyright     |
  13.  * | notice, this list of conditions and the following disclaimer.        |
  14.  * | - Redistributions in binary form must reproduce the above copyright  |
  15.  * | notice, this list of conditions and the following disclaimer in the  |
  16.  * | documentation and/or other materials provided with the distribution. |
  17.  * | - Neither the name of the The PEAR Group nor the names of its        |
  18.  * | contributors may be used to endorse or promote products derived from |
  19.  * | this software without specific prior written permission.             |
  20.  * |                                                                      |
  21.  * | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  |
  22.  * | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT    |
  23.  * | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    |
  24.  * | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE       |
  25.  * | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,  |
  26.  * | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
  27.  * | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;     |
  28.  * | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER     |
  29.  * | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT   |
  30.  * | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN    |
  31.  * | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE      |
  32.  * | POSSIBILITY OF SUCH DAMAGE.                                          |
  33.  * +----------------------------------------------------------------------+
  34.  *
  35.  * PHP Version 5
  36.  *
  37.  * @category File_Formats
  38.  * @package  File_IMC
  39.  * @author   Till Klampaeckel <till@php.net>
  40.  * @license  http://www.opensource.org/licenses/bsd-license.php The BSD License
  41.  * @version  SVN: $Id$
  42.  * @link     http://pear.php.net/package/File_IMC
  43.  */
  44.  
  45. /**
  46. * File_IMC_Parse_Vcalendar_Events
  47. *
  48. * <code>
  49. *   $parser = File_IMC::parse('vcalendar');
  50. *   $parser->fromFile('path/to/sample.vcs');
  51. *
  52. *   $events = $parser->getEvents();
  53. *
  54. *   while ($events->valid()) {
  55. *       $event = $events->current();
  56. *       $events->next();
  57. *   }
  58. * </code>
  59. *
  60. @category File_Formats
  61. @package  File_IMC
  62. @author   Till Klampaeckel <till@php.net>
  63. @license  http://www.opensource.org/licenses/bsd-license.php The BSD License
  64. @version  Release: 0.5.0
  65. @link     http://pear.php.net/package/File_IMC
  66. */
  67. class File_IMC_Parse_Vcalendar_Events extends ArrayIterator
  68. {
  69.     protected $data;
  70.     protected $index;
  71.  
  72.     public function __construct(array $data)
  73.     {
  74.         $this->data  = $data;
  75.         $this->index = 0;
  76.     }
  77.  
  78.     public function append($value)
  79.     {
  80.     }
  81.  
  82.     public function count()
  83.     {
  84.         return count($this->data);
  85.     }
  86.  
  87.     public function current()
  88.     {
  89.         return new File_IMC_Parse_Vcalendar_Event($this->data[$this->index]);
  90.     }
  91.  
  92.     /*
  93.     public function get($index)
  94.     {
  95.         if (isset($this->data[$index])) {
  96.             return $this->data[$index];
  97.         }
  98.         throw File_IMC_Exception("Invalid index.");
  99.     }
  100.     */
  101.  
  102.     public function key()
  103.     {
  104.         return $this->index;
  105.     }
  106.  
  107.     public function next()
  108.     {
  109.         ++$this->index;
  110.     }
  111.  
  112.     public function rewind()
  113.     {
  114.         $this->index = 0;
  115.     }
  116.  
  117.     public function seek($position)
  118.     {
  119.         $this->index = $position;
  120.     }
  121.  
  122.     public function valid()
  123.     {
  124.         if (isset($this->data[$this->index])) {
  125.             return true;
  126.         }
  127.         return false;
  128.     }
  129. }

Documentation generated on Mon, 11 Mar 2019 15:49:38 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.