ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DurationValidator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
27{
28 use DataFetcher;
29
31
32 public function __construct(
34 ) {
35 $this->data_helper = $data_helper;
36 }
37
38 public function isValid(
39 ElementInterface $element,
40 bool $ignore_marker
41 ): bool {
42 $value = $this->dataValue($element, $ignore_marker);
43 if (!$this->data_helper->matchesDurationPattern($value)) {
44 return false;
45 }
46 foreach ($this->data_helper->durationToIterator($value) as $match) {
47 if (isset($match) && (int) $match < 0) {
48 return false;
49 }
50 }
51 return true;
52 }
53}
isValid(ElementInterface $element, bool $ignore_marker)