PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/ezcomponents/Workflow/src/conditions/in_array.php

http://hppg.googlecode.com/
PHP | 69 lines | 20 code | 5 blank | 44 comment | 1 complexity | 95ba96d265ea47f3c2e97db5cdbdfab8 MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause
  1. <?php
  2. /**
  3. * File containing the ezcWorkflowConditionInArray class.
  4. *
  5. * @package Workflow
  6. * @version 1.4.1
  7. * @copyright Copyright (C) 2005-2010 eZ Systems AS. All rights reserved.
  8. * @license http://ez.no/licenses/new_bsd New BSD License
  9. */
  10. /**
  11. * Condition that checks if a value is in an array.
  12. *
  13. * Typically used together with ezcWorkflowConditionVariable to use the
  14. * condition on a workflow variable.
  15. *
  16. * <code>
  17. * <?php
  18. * $condition = new ezcWorkflowConditionVariable(
  19. * 'variable name',
  20. * new ezcWorkflowConditionInArray( array( ... ) )
  21. * );
  22. * ?>
  23. * </code>
  24. *
  25. * @package Workflow
  26. * @version 1.4.1
  27. */
  28. class ezcWorkflowConditionInArray extends ezcWorkflowConditionComparison
  29. {
  30. /**
  31. * Textual representation of the comparison operator.
  32. *
  33. * @var mixed
  34. */
  35. protected $operator = 'in array';
  36. /**
  37. * Evaluates this condition with $value and returns true if it is false or false if it is not.
  38. *
  39. * @param mixed $value
  40. * @return boolean true when the condition holds, false otherwise.
  41. * @ignore
  42. */
  43. public function evaluate( $value )
  44. {
  45. return in_array( $value, $this->value );
  46. }
  47. /**
  48. * Returns a textual representation of this condition.
  49. *
  50. * @return string
  51. * @ignore
  52. */
  53. public function __toString()
  54. {
  55. $array = $this->value;
  56. $count = count( $array );
  57. for ( $i = 0; $i < $count; $i++ )
  58. {
  59. $array[$i] = var_export( $array[$i], true );
  60. }
  61. return $this->operator . '(' . join( ', ', $array ) . ')';
  62. }
  63. }
  64. ?>