Source for file Quiet.php

Documentation is available at Quiet.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6. * ScriptReorganizer Strategy :: Quiet
  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 Strategy
  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: Quiet.php 21 2005-09-26 15:55:48Z stefanorausch $
  22. * @link http://pear.php.net/package/ScriptReorganizer
  23. * @filesource
  24. */
  25.  
  26. /**
  27. * Implements <kbd>ScriptReorganizer_Strategy</kbd>
  28. */
  29. require_once 'ScriptReorganizer/Strategy.php';
  30.  
  31. /**
  32. * Uses <kbd>ScriptReorganizer_Strategy_Route</kbd>
  33. */
  34. require_once 'ScriptReorganizer/Strategy/Route.php';
  35.  
  36. /**
  37. * Standard strategy
  38. *
  39. * Reorganizes scripts by stripping off single and multiple line comments as well as
  40. * by applying the {@link ScriptReorganizer_Strategy_Route Route} strategy.
  41. *
  42. * @category Tools
  43. * @package ScriptReorganizer
  44. * @subpackage Strategy
  45. * @author Stefano F. Rausch <stefano@rausch-e.net>
  46. * @copyright 2005 Stefano F. Rausch <stefano@rausch-e.net>
  47. * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
  48. * @version Release: 0.4.0
  49. * @link http://pear.php.net/package/ScriptReorganizer
  50. */
  51. class ScriptReorganizer_Strategy_Quiet implements ScriptReorganizer_Strategy
  52. {
  53. // {{{ public function __construct()
  54. /**
  55. * Constructor
  56. */
  57. public function __construct()
  58. {
  59. $this->route = new ScriptReorganizer_Strategy_Route;
  60. }
  61. // }}}
  62. // {{{ public function reformat( & $content, $eol )
  63. /**
  64. * Performs the main reorganization of the script's content
  65. *
  66. * @param string &$content a string representing the script's content
  67. * @param string $eol a string representing the EOL identifier to use
  68. * @return string a string representing the reorganized content
  69. */
  70. public function reformat( & $content, $eol )
  71. {
  72. $identifiers = array(
  73. 'multiLineComments' => '"[{};,' . $eol . ']([ \t]*/\*(.|[' . $eol . '])*?\*/)"',
  74. 'singleLineComments' => '"[{};,' . $eol . ']([ \t]*//[^' . $eol . ']*)"'
  75. );
  76. foreach ( $identifiers as $identifier ) {
  77. if ( preg_match_all( $identifier, $content, $matches ) ) {
  78. foreach ( $matches[1] as $comment ) {
  79. $content = str_replace( $comment, '', $content );
  80. }
  81. }
  82. }
  83. return $this->route->reformat( $content, $eol );
  84. }
  85. // }}}
  86. // {{{ private properties
  87. /**
  88. * Holds the helper strategy
  89. *
  90. * @var ScriptReorganizer_Strategy_Route
  91. */
  92. private $route = null;
  93. // }}}
  94.  
  95. }
  96.  
  97. /*
  98. * Local variables:
  99. * tab-width: 4
  100. * c-basic-offset: 4
  101. * c-hanging-comment-ender-p: nil
  102. * End:
  103. */
  104.  
  105. ?>

Documentation generated on Tue, 22 Nov 2005 01:57:12 +0100 by phpDocumentor 1.3.0RC3