ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
4 namespace ILIAS\Refinery\Logical;
5 
7 use ILIAS\Data;
8 
14 class LogicalOr extends Constraint
15 {
19  protected $other = [];
20 
26  public function __construct(array $other, Data\Factory $data_factory, \ilLanguage $lng)
27  {
28  $this->other = $other;
29 
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->getErrorMessage($value);
45  }
46 
47  return 'Please fix one of these: ' . implode(', ', array_filter($problems));
48  },
49  $data_factory,
50  $lng
51  );
52  }
53 }
__construct(array $other, Data\Factory $data_factory, \ilLanguage $lng)
LogicalOr constructor.
Definition: LogicalOr.php:26
A constraint encodes some resrtictions on values.
Definition: Constraint.php:14
$lng
Builds data types.
Definition: Factory.php:19
__construct(Container $dic, ilPlugin $plugin)
language handling