api de gestion de ticket, basé sur php-crud-api. Le but est de décorrélé les outils de gestion des données, afin
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AndCondition.php 818B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Tqdev\PhpCrudApi\Record\Condition;
  3. class AndCondition extends Condition
  4. {
  5. private $conditions;
  6. public function __construct(Condition $condition1, Condition $condition2)
  7. {
  8. $this->conditions = [$condition1, $condition2];
  9. }
  10. public function _and(Condition $condition): Condition
  11. {
  12. if ($condition instanceof NoCondition) {
  13. return $this;
  14. }
  15. $this->conditions[] = $condition;
  16. return $this;
  17. }
  18. public function getConditions(): array
  19. {
  20. return $this->conditions;
  21. }
  22. public static function fromArray(array $conditions): Condition
  23. {
  24. $condition = new NoCondition();
  25. foreach ($conditions as $c) {
  26. $condition = $condition->_and($c);
  27. }
  28. return $condition;
  29. }
  30. }