PageRenderTime 49ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://hppg.googlecode.com/
PHP | 81 lines | 37 code | 5 blank | 39 comment | 5 complexity | 2d20e689d2ce698642ca05a04dbe26f2 MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause
  1. <?php
  2. /**
  3. * File containing the ezcTemplateIssetAstNode 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 isset construct.
  13. *
  14. * @package Template
  15. * @version 1.4.2
  16. * @access private
  17. */
  18. class ezcTemplateIssetAstNode 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 $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. */
  51. public function appendExpression( ezcTemplateAstNode $expression )
  52. {
  53. $this->expressions[] = $expression;
  54. }
  55. /**
  56. * Returns a list of expressions which will be checked for existance.
  57. * @return array(ezcTemplateAstNode)
  58. */
  59. public function getExpressions()
  60. {
  61. return $this->expressions;
  62. }
  63. /**
  64. * Validates the expressions against their constraints.
  65. *
  66. * @throws ezcTemplateInternalException if the constraints are not met.
  67. */
  68. public function validate()
  69. {
  70. if ( count( $this->expressions ) == 0 )
  71. {
  72. throw new ezcTemplateInternalException( "Too few expressions for class <" . get_class( $this ) . ">, needs at least 1 but got 0." );
  73. }
  74. }
  75. }
  76. ?>