ILIAS  release_7 Revision v7.30-3-g800a261c036
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 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}
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:20
__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
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$lng