TYPO3
7.6
Users
bogdan
Projects
Kapeli
Resources
Dash
Docsets
TYPO3
src
vendor
symfony
finder
Comparator
Comparator.php
Go to the documentation of this file.
1
<?php
2
3
/*
4
* This file is part of the Symfony package.
5
*
6
* (c) Fabien Potencier <fabien@symfony.com>
7
*
8
* For the full copyright and license information, please view the LICENSE
9
* file that was distributed with this source code.
10
*/
11
12
namespace
Symfony\Component\Finder\Comparator;
13
19
class
Comparator
20
{
21
private
$target
;
22
private
$operator =
'=='
;
23
29
public
function
getTarget
()
30
{
31
return
$this->target
;
32
}
33
39
public
function
setTarget
(
$target
)
40
{
41
$this->target =
$target
;
42
}
43
49
public
function
getOperator
()
50
{
51
return
$this->operator;
52
}
53
61
public
function
setOperator
($operator)
62
{
63
if
(!$operator) {
64
$operator =
'=='
;
65
}
66
67
if
(!in_array($operator, array(
'>'
,
'<'
,
'>='
,
'<='
,
'=='
,
'!='
))) {
68
throw
new \InvalidArgumentException(sprintf(
'Invalid operator "%s".'
, $operator));
69
}
70
71
$this->
operator
= $operator;
72
}
73
81
public
function
test
($test)
82
{
83
switch
($this->
operator
) {
84
case
'>'
:
85
return
$test >
$this->target
;
86
case
'>='
:
87
return
$test >=
$this->target
;
88
case
'<'
:
89
return
$test <
$this->target
;
90
case
'<='
:
91
return
$test <=
$this->target
;
92
case
'!='
:
93
return
$test !=
$this->target
;
94
}
95
96
return
$test ==
$this->target
;
97
}
98
}
Generated on Wed Nov 11 2015 01:51:51 for TYPO3 by
1.8.3