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

Source for file SplitTextByLineBreak.php

Documentation is available at SplitTextByLineBreak.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_Config_ParseOptions
  18.  * @copyright   Copyright (c) 2009 Sven Strittmatter
  19.  */
  20.  
  21. /**
  22.  * @see MediaSearch_Config_ParseOptions_Interface
  23.  */
  24. require_once('MediaSearch/Config/ParseOptions/Interface.php');
  25.  
  26.  /**
  27.   * This concrete implementaion of a parse option splits the
  28.   * given input string by any linebreak and returns an array.
  29.   *
  30.   * @category   MediaSearch
  31.   * @package    MediaSearch_Config_ParseOptions
  32.   * @copyright  Copyright (c) 2009 Sven Strittmatter
  33.   */
  34. class MediaSearch_Config_ParseOptions_SplitTextByLineBreak implements MediaSearch_Config_ParseOptions_Interface {
  35.     const TRACE_LELVEL 8;
  36.  
  37.     /**
  38.      * Expects a string as input and splitts it on any occured line break.
  39.      * Returns an array of strings.
  40.      *
  41.      * @accesss public
  42.      * @param string $input 
  43.      * @return array 
  44.      */
  45.     public function parse($input{
  46.         if (!is_string($input)) {
  47.             $message 'This option expects strings as input!';
  48.             throw new InvalidArgumentException($message);
  49.         }
  50.            
  51.         return preg_split('/[\s]+/',
  52.                           $input,
  53.                           -1,
  54.                           PREG_SPLIT_NO_EMPTY);
  55.     }
  56. }

Documentation generated on Mon, 17 Aug 2009 14:54:03 +0200 by phpDocumentor 1.4.2