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

Source for file AddHeader.php

Documentation is available at AddHeader.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * ScriptReorganizer Type Decorator :: AddHeader
  7.  *
  8.  * PHP version 5
  9.  *
  10.  * LICENSE: This library is free software; you can redistribute it and/or modify it
  11.  * under the terms of the GNU Lesser General Public License as published by the Free
  12.  * Software Foundation; either version 2.1 of the License, or (at your option) any
  13.  * later version.
  14.  *
  15.  * @category   Tools
  16.  * @package    ScriptReorganizer
  17.  * @subpackage Type_Decorator
  18.  * @author     Stefano F. Rausch <stefano@rausch-e.net>
  19.  * @copyright  2005 Stefano F. Rausch <stefano@rausch-e.net>
  20.  * @license    http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  21.  * @version    SVN: $Id: AddHeader.php 32 2005-10-30 22:05:19Z stefanorausch $
  22.  * @link       http://pear.php.net/package/ScriptReorganizer
  23.  * @filesource
  24.  */
  25.  
  26. /**
  27.  * Depends on <kbd>ScriptReorganizer_Type</kbd>
  28.  */
  29. require_once 'ScriptReorganizer/Type.php';
  30.  
  31. /**
  32.  * Extends <kbd>ScriptReorganizer_Type_Decorator</kbd>
  33.  */
  34. require_once 'ScriptReorganizer/Type/Decorator.php';
  35.  
  36. /**
  37.  * Throws <kbd>ScriptReorganizer_Type_Decorator_Exception</kbd>
  38.  */
  39. require_once 'ScriptReorganizer/Type/Decorator/Exception.php';
  40.  
  41. /**
  42.  * Decorator for adding a header to the script to reorganize
  43.  *
  44.  * ANN: Decoration of a directly sequencing Pharize-Decorator is not allowed.
  45.  *
  46.  * @category   Tools
  47.  * @package    ScriptReorganizer
  48.  * @subpackage Type_Decorator
  49.  * @author     Stefano F. Rausch <stefano@rausch-e.net>
  50.  * @copyright  2005 Stefano F. Rausch <stefano@rausch-e.net>
  51.  * @license    http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  52.  * @version    Release: @package_version@
  53.  * @link       http://pear.php.net/package/ScriptReorganizer
  54.  */
  55. {
  56.     // {{{ public function __construct( ScriptReorganizer_Type $type, $header = '' )
  57.     
  58.     /**
  59.      * Constructor
  60.      *
  61.      * @param  ScriptReorganizer_Type $type a <kbd>ScriptReorganizer_Type</kbd> to
  62.      *          decorate
  63.      * @param  string $header a string representing the (optional) default header to
  64.      *          prepend
  65.      * @throws {@link ScriptReorganizer_Type_Decorator_Exception ScriptReorganizer_Type_Decorator_Exception}
  66.      */
  67.     public function __constructScriptReorganizer_Type $type$header '' )
  68.     {
  69.         if class_exists'ScriptReorganizer_Type_Decorator_Pharize'false ) ) {
  70.             if $type instanceof ScriptReorganizer_Type_Decorator_Pharize {
  71.                 throw new ScriptReorganizer_Type_Decorator_Exception(
  72.                     'Decoration of a directly sequencing Pharize-Decorator not allowed'
  73.                 );
  74.             }
  75.         }
  76.         
  77.         parent::__construct$type );
  78.         
  79.         $this->header $header;
  80.     }
  81.     
  82.     // }}}
  83.     
  84.     // {{{ public function reformat( $header = null )
  85.     
  86.     /**
  87.      * Reorganizes the script's content by applying the chosen
  88.      * {@link ScriptReorganizer_Strategy Strategy}
  89.      *
  90.      * @param  string $header a string representing the (optional) overriding header
  91.      *          to prepend
  92.      * @return void 
  93.      * @throws {@link ScriptReorganizer_Type_Decorator_Exception ScriptReorganizer_Type_Decorator_Exception}
  94.      */
  95.     public function reformat$header = null )
  96.     {
  97.         if null !== $header {
  98.             $this->header $header;
  99.         }
  100.         
  101.         if !is_string$this->header ) ) {
  102.             throw new ScriptReorganizer_Type_Decorator_Exception (
  103.                 'Argument $header for AddHeader-Decorator not of type string'
  104.             );
  105.         }
  106.         
  107.         parent::reformat();
  108.         $this->_setContent$this->header $this->_getContent() );
  109.     }
  110.     
  111.     // }}}
  112.     
  113.     // {{{ private properties
  114.     
  115.     /**
  116.      * Holds the header to prepend
  117.      *
  118.      * @var string 
  119.      */
  120.     private $header = null;
  121.     
  122.     // }}}
  123. }
  124.  
  125. /*
  126.  * Local variables:
  127.  * tab-width: 4
  128.  * c-basic-offset: 4
  129.  * c-hanging-comment-ender-p: nil
  130.  * End:
  131.  */
  132.  
  133. ?>

Documentation generated on Mon, 11 Mar 2019 14:10:29 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.