ILIAS
trunk Revision v11.0_alpha-2645-g16283d3b3f8
◀ ilDoc Overview
DateComparator.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
namespace
ILIAS\Filesystem\Finder\Comparator
;
22
23
use
Exception
;
24
use
InvalidArgumentException
;
25
31
class
DateComparator
extends
BaseComparator
32
{
33
public
function
__construct
(
string
$test)
34
{
35
if
(!preg_match(
'#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i'
, $test, $matches)) {
36
throw
new
InvalidArgumentException
(sprintf(
'Don\'t understand "%s" as a date test.'
, $test));
37
}
38
39
try
{
40
$date = new \DateTime($matches[2]);
41
$target
= $date->format(
'U'
);
42
}
catch
(
Exception
) {
43
throw
new
InvalidArgumentException
(sprintf(
'"%s" is not a valid date.'
, $matches[2]));
44
}
45
46
$operator = $matches[1] ??
'=='
;
47
48
if
(
'since'
=== $operator ||
'after'
=== $operator) {
49
$operator =
'>'
;
50
}
51
52
if
(
'until'
=== $operator ||
'before'
=== $operator) {
53
$operator =
'<'
;
54
}
55
56
$this->
setOperator
($operator);
57
$this->
setTarget
(
$target
);
58
}
59
}
ILIAS\Filesystem\Finder\Finder::Comparator\BaseComparator\setTarget
setTarget(string $target)
Definition:
BaseComparator.php:40
ILIAS\Filesystem\Finder\Comparator
Definition:
BaseComparator.php:21
ILIAS\Filesystem\Finder\Comparator\DateComparator
Definition:
DateComparator.php:31
ILIAS\Filesystem\Finder\Finder::Comparator\BaseComparator\$target
string $target
Definition:
BaseComparator.php:32
ILIAS\Filesystem\Finder\Comparator\DateComparator\__construct
__construct(string $test)
Definition:
DateComparator.php:33
ILIAS\Filesystem\Finder\Finder::Comparator\BaseComparator\setOperator
setOperator(string $operator)
Definition:
BaseComparator.php:50
InvalidArgumentException
Exception
components
ILIAS
Filesystem
src
Finder
Comparator
DateComparator.php
Generated on Mon Sep 1 2025 23:03:07 for ILIAS by
1.8.13 (using
Doxyfile
)