Source for file AddFooter.php

Documentation is available at AddFooter.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6. * ScriptReorganizer Type Decorator :: AddFooter
  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: AddFooter.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 footer 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: 0.3.0
  53. * @link http://pear.php.net/package/ScriptReorganizer
  54. */
  55. class ScriptReorganizer_Type_Decorator_AddFooter extends ScriptReorganizer_Type_Decorator
  56. {
  57. // {{{ public function __construct( ScriptReorganizer_Type $type, $footer = '' )
  58. /**
  59. * Constructor
  60. *
  61. * @param ScriptReorganizer_Type $type a <kbd>ScriptReorganizer_Type</kbd> to
  62. * decorate
  63. * @param string $footer a string representing the (optional) default footer to
  64. * append
  65. * @throws {@link ScriptReorganizer_Type_Decorator_Exception ScriptReorganizer_Type_Decorator_Exception}
  66. */
  67. public function __construct( ScriptReorganizer_Type $type, $footer = '' )
  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. parent::__construct( $type );
  77. $this->footer = $footer;
  78. }
  79. // }}}
  80. // {{{ public function reformat( $footer = null )
  81. /**
  82. * Reorganizes the script's content by applying the chosen
  83. * {@link ScriptReorganizer_Strategy Strategy}
  84. *
  85. * @param string $footer a string representing the (optional) overriding footer
  86. * to append
  87. * @return void
  88. * @throws {@link ScriptReorganizer_Type_Decorator_Exception ScriptReorganizer_Type_Decorator_Exception}
  89. */
  90. public function reformat( $footer = null )
  91. {
  92. if ( null !== $footer ) {
  93. $this->footer = $footer;
  94. }
  95. if ( !is_string( $this->footer ) ) {
  96. throw new ScriptReorganizer_Type_Decorator_Exception (
  97. 'Argument $footer for AddFooter-Decorator not of type string'
  98. );
  99. }
  100. parent::reformat();
  101. $this->_setContent( $this->_getContent() . $this->footer );
  102. }
  103. // }}}
  104. // {{{ private properties
  105. /**
  106. * Holds the footer to append
  107. *
  108. * @var string
  109. */
  110. private $footer = null;
  111. // }}}
  112.  
  113. }
  114.  
  115. /*
  116. * Local variables:
  117. * tab-width: 4
  118. * c-basic-offset: 4
  119. * c-hanging-comment-ender-p: nil
  120. * End:
  121. */
  122.  
  123. ?>

Documentation generated on Sun, 6 Nov 2005 22:48:08 +0100 by phpDocumentor 1.3.0RC3