PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/ezcomponents/Template/src/syntax_trees/ast/nodes/constructs/unset.php

http://hppg.googlecode.com/
PHP | 83 lines | 37 code | 5 blank | 41 comment | 5 complexity | 496090a28367f1cadcd8a3c47e853f83 MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause
  1. <?php
  2. /**
  3. * File containing the ezcTemplateUnsetAstNode class
  4. *
  5. * @package Template
  6. * @version 1.4.2
  7. * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
  8. * @license http://ez.no/licenses/new_bsd New BSD License
  9. * @access private
  10. */
  11. /**
  12. * Represents an unset construct.
  13. *
  14. * @package Template
  15. * @version 1.4.2
  16. * @access private
  17. */
  18. class ezcTemplateUnsetAstNode extends ezcTemplateStatementAstNode
  19. {
  20. /**
  21. * The expression to evaluate if exists.
  22. * @var array(ezcTemplateAstNode)
  23. */
  24. public $expressions;
  25. /**
  26. * Initialize with function name code and optional arguments
  27. *
  28. * @param array(ezcTemplateAstNode) $expressions
  29. */
  30. public function __construct( Array $expressions = null )
  31. {
  32. parent::__construct();
  33. $this->expressions = array();
  34. if ( $expressions !== null )
  35. {
  36. foreach ( $expressions as $id => $expression )
  37. {
  38. if ( !$expression instanceof ezcTemplateAstNode )
  39. {
  40. throw new ezcBaseValueException( "expressions[$id]", $expression, 'ezcTemplateAstNode' );
  41. }
  42. $this->expressions[] = $expression;
  43. }
  44. }
  45. }
  46. /**
  47. * Appends the expression to be checked for existance.
  48. *
  49. * @param ezcTemplateAstNode $expression Expression to check.
  50. * @return void
  51. */
  52. public function appendExpression( ezcTemplateAstNode $expression )
  53. {
  54. $this->expressions[] = $expression;
  55. }
  56. /**
  57. * Returns a list of expressions which will be checked for existance.
  58. * @return array(ezcTemplateAstNode)
  59. */
  60. public function getExpressions()
  61. {
  62. return $this->expressions;
  63. }
  64. /**
  65. * Validates the expressions against their constraints.
  66. *
  67. * @throws ezcTemplateInternalException if the constraints are not met.
  68. * @return void
  69. */
  70. public function validate()
  71. {
  72. if ( count( $this->expressions ) == 0 )
  73. {
  74. throw new ezcTemplateInternalException( "Too few expressions for class <" . get_class( $this ) . ">, needs at least 1 but got 0." );
  75. }
  76. }
  77. }
  78. ?>