ILIAS
release_8 Revision v8.19
◀ ilDoc Overview
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
$
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
x
+
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
+
Variables
$
a
b
c
d
e
f
g
h
j
l
m
p
s
t
u
+
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
+
Data Fields
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Ö
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
$
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Ö
+
Files
File List
+
Globals
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
+
Functions
_
a
b
c
d
e
g
h
i
m
n
p
r
s
t
u
v
x
+
Variables
$
a
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
z
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Modules
Pages
NumberComparator.php
Go to the documentation of this file.
1
<?php
2
3
declare(strict_types=1);
4
5
namespace
ILIAS\Filesystem\Finder\Comparator
;
6
7
use
InvalidArgumentException
;
8
9
/******************************************************************************
10
*
11
* This file is part of ILIAS, a powerful learning management system.
12
*
13
* ILIAS is licensed with the GPL-3.0, you should have received a copy
14
* of said license along with the source code.
15
*
16
* If this is not the case or you just want to try ILIAS, you'll find
17
* us at:
18
* https://www.ilias.de
19
* https://github.com/ILIAS-eLearning
20
*
21
*****************************************************************************/
22
28
class
NumberComparator
extends
BaseComparator
29
{
30
public
function
__construct
(
string
$test)
31
{
32
if
(!preg_match(
'#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i'
, $test, $matches)) {
33
throw
new
InvalidArgumentException
(sprintf(
'Don\'t understand "%s" as a number test.'
, $test));
34
}
35
36
$target
= $matches[2];
37
if
(!is_numeric(
$target
)) {
38
throw
new
InvalidArgumentException
(sprintf(
'Invalid number "%s".'
,
$target
));
39
}
40
41
if
(isset($matches[3])) {
42
switch
(strtolower($matches[3])) {
43
case
'k'
:
44
$target
*= 1000;
45
break
;
46
47
case
'ki'
:
48
$target
*= 1024;
49
break
;
50
51
case
'm'
:
52
$target
*= 1_000_000;
53
break
;
54
55
case
'mi'
:
56
$target
*= 1024 * 1024;
57
break
;
58
59
case
'g'
:
60
$target
*= 1_000_000_000;
61
break
;
62
63
case
'gi'
:
64
$target
*= 1024 * 1024 * 1024;
65
break
;
66
}
67
}
68
69
$this->
setTarget
((
string
)
$target
);
70
$this->
setOperator
($matches[1] ??
'=='
);
71
}
72
}
ILIAS\Filesystem\Finder\Comparator\BaseComparator\$target
string $target
Definition:
BaseComparator.php:30
ILIAS\Filesystem\Finder\Comparator\BaseComparator
Definition:
BaseComparator.php:28
ILIAS\Filesystem\Finder\Comparator\NumberComparator\__construct
__construct(string $test)
Definition:
NumberComparator.php:30
ILIAS\Filesystem\Finder\Comparator\NumberComparator
Definition:
NumberComparator.php:28
ILIAS\Filesystem\Finder\Comparator
Definition:
BaseComparator.php:5
ILIAS\Filesystem\Finder\Comparator\BaseComparator\setOperator
setOperator(string $operator)
Definition:
BaseComparator.php:48
ILIAS\Filesystem\Finder\Comparator\BaseComparator\setTarget
setTarget(string $target)
Definition:
BaseComparator.php:38
InvalidArgumentException
src
Filesystem
Finder
Comparator
NumberComparator.php
Generated on Thu Apr 10 2025 22:02:55 for ILIAS by
1.8.13 (using
Doxyfile
)