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

Source for file List.php

Documentation is available at List.php

  1. <?php
  2. /**
  3.  * MediaSearch
  4.  *
  5.  * LICENSE
  6.  *
  7.  * "THE BEER-WARE LICENSE" (Revision 42):
  8.  * "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
  9.  * As long as you retain this notice you can do whatever you want with
  10.  * this stuff. If we meet some day, and you think this stuff is worth it,
  11.  * you can buy me a beer in return.
  12.  *
  13.  * $Author$
  14.  * $Revision$
  15.  *
  16.  * @category    MediaSearch
  17.  * @package     MediaSearch_Scan
  18.  * @copyright   Copyright (c) 2009 Sven Strittmatter
  19.  */
  20.  
  21. /**
  22.   * @todo Write apidoc.
  23.   *
  24.   * @category   MediaSearch
  25.   * @package    MediaSearch_Scan
  26.   * @copyright  Copyright (c) 2009 Sven Strittmatter
  27.   */
  28. class MediaSearch_Scan_List implements Countable, Iterator {
  29.     const TRACE_LELVEL = 50;
  30.  
  31.     protected $list;
  32.     protected $index;
  33.  
  34.     public function __construct() {
  35.         $this->list  = array();
  36.         $this->index = 0;
  37.     }
  38.  
  39.     public function add(MediaSearch_Scan_FileMeta $fm) {
  40.         $this->list[] = $fm;
  41.     }
  42.  
  43.     // implementation for Countable:
  44.     public function count() {
  45.         return count($this->list);
  46.     }
  47.  
  48.     // implementation of Iterator:
  49.     public function current() {
  50.         return $this->list[$this->index];
  51.     }
  52.  
  53.     public function key () {
  54.         return $this->index;
  55.     }
  56.  
  57.     public function next() {
  58.         $this->index++;
  59.     }
  60.  
  61.     public function rewind() {
  62.         $this->index = 0;
  63.     }
  64.  
  65.     public function valid() {
  66.         return array_key_exists($this->index, $this->list);
  67.     }
  68.  
  69.     public function __toString() {
  70.         $return = '';
  71.  
  72.         if ($this->count() > 0) {
  73.             foreach ($this->list as $fileMeta) {
  74.                 $return .= $fileMeta . "\n";
  75.             }
  76.         } else {
  77.             $return = "[empty]\n";
  78.         }
  79.  
  80.         return $return;
  81.     }
  82. }

Documentation generated on Mon, 17 Aug 2009 14:53:29 +0200 by phpDocumentor 1.4.2