ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LogicalOr.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
5
7use ILIAS\Data;
8
14class LogicalOr extends Custom implements Constraint
15{
19 protected $other = [];
20
26 public function __construct(array $other, Data\Factory $data_factory, \ilLanguage $lng)
27 {
28 $this->other = $other;
29
30 parent::__construct(
31 function ($value) {
32 foreach ($this->other as $constraint) {
33 if ($constraint->accepts($value)) {
34 return true;
35 }
36 }
37
38 return false;
39 },
40 function ($value) {
41 $problems = [];
42
43 foreach ($this->other as $constraint) {
44 $problems[] = (string) $constraint->problemWith($value);
45 }
46
47 return 'Please fix one of these: ' . implode(', ', array_filter($problems));
48 },
50 $lng
51 );
52 }
53}
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:15
__construct(array $other, Data\Factory $data_factory, \ilLanguage $lng)
LogicalOr constructor.
Definition: LogicalOr.php:26
language handling
A constraint encodes some resrtictions on values.
Definition: Constraint.php:15