1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* AppserverIo\Resources\Predicates\SystemLocaleExistsPredicate |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2018 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/appserver-io/resources |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace AppserverIo\Resources\Predicates; |
22
|
|
|
|
23
|
|
|
use AppserverIo\Resources\SystemLocale; |
24
|
|
|
use AppserverIo\Collections\PredicateInterface; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* This class is the predicate for checking the passed SystemLocale to be in the ArrayList with the |
28
|
|
|
* installed system locales. |
29
|
|
|
* |
30
|
|
|
* @author Tim Wagner <[email protected]> |
31
|
|
|
* @copyright 2018 TechDivision GmbH <[email protected]> |
32
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
33
|
|
|
* @link https://github.com/appserver-io/resources |
34
|
|
|
* @link http://www.appserver.io |
35
|
|
|
*/ |
36
|
|
|
class SystemLocaleExistsPredicate implements PredicateInterface |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Holds the SystemLocale the check the system locales for. |
41
|
|
|
* |
42
|
|
|
* @var \AppserverIo\Resources\SystemLocale |
43
|
|
|
*/ |
44
|
|
|
protected $locale = null; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Constructor that initializes the internal member |
48
|
|
|
* with the value passed as parameter. |
49
|
|
|
* |
50
|
|
|
* @param \AppserverIo\Resources\SystemLocale $locale Holds the locale to check the system locales for |
51
|
|
|
* |
52
|
|
|
* @return void |
53
|
|
|
*/ |
54
|
|
|
public function __construct(SystemLocale $locale) |
55
|
|
|
{ |
56
|
|
|
$this->locale = $locale; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* This method evaluates the objects passed as parameter against |
61
|
|
|
* the internal member and returns true if the locales are equal. |
62
|
|
|
* |
63
|
|
|
* @param \AppserverIo\Resources\SystemLocale $object Holds the object for the evaluation |
64
|
|
|
* |
65
|
|
|
* @return boolean Returns TRUE if the passed Locale equals to the internal one |
66
|
|
|
*/ |
67
|
|
|
public function evaluate($object) |
68
|
|
|
{ |
69
|
|
|
|
70
|
|
|
// return TRUE, if the passed SystemLocale are equal |
71
|
|
|
if ($this->locale->__toString() === $object->__toString()) { |
72
|
|
|
return true; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
// if not, return FALSE |
76
|
|
|
return false; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|