Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
30 / 30 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
common_configuration_PHPRuntime | |
100.00% |
30 / 30 |
|
100.00% |
3 / 3 |
13 | |
100.00% |
1 / 1 |
check | |
100.00% |
26 / 26 |
|
100.00% |
1 / 1 |
11 | |||
getValue | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * This program is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU General Public License |
6 | * as published by the Free Software Foundation; under version 2 |
7 | * of the License (non-upgradable). |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write to the Free Software |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | * |
18 | * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg |
19 | * (under the project TAO & TAO2); |
20 | * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung |
21 | * (under the project TAO-TRANSFER); |
22 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
23 | * (under the project TAO-SUSTAIN & TAO-DEV); |
24 | * |
25 | */ |
26 | |
27 | /** |
28 | * Short description of class common_configuration_PHPRuntime |
29 | * |
30 | * @access public |
31 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
32 | * @package generis |
33 | |
34 | */ |
35 | class common_configuration_PHPRuntime extends common_configuration_BoundableComponent |
36 | { |
37 | // --- ASSOCIATIONS --- |
38 | |
39 | |
40 | // --- ATTRIBUTES --- |
41 | |
42 | // --- OPERATIONS --- |
43 | |
44 | /** |
45 | * Short description of method check |
46 | * |
47 | * @access public |
48 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
49 | * @return common_configuration_Report |
50 | */ |
51 | public function check() |
52 | { |
53 | $returnValue = null; |
54 | |
55 | |
56 | $validity = null; |
57 | $message = null; |
58 | $min = $this->getMin(); |
59 | $max = $this->getMax(); |
60 | $current = $this->getValue(); |
61 | |
62 | if (!empty($min) && !empty($max)) { |
63 | // min & max are specifed. |
64 | if (version_compare($current, $min, '>=') && version_compare($current, $max, '<=')) { |
65 | $validity = common_configuration_Report::VALID; |
66 | $message = "PHP Version (${current}) is between ${min} and ${max}."; |
67 | } else { |
68 | $validity = common_configuration_Report::INVALID; |
69 | $message = "PHP Version (${current} is not between ${min} and ${max}.)"; |
70 | } |
71 | } elseif (!empty($min) && empty($max)) { |
72 | if (version_compare($current, $min, '>=')) { |
73 | $validity = common_configuration_Report::VALID; |
74 | $message = "PHP Version (${current}) is higher or equal to ${min}."; |
75 | } else { |
76 | $validity = common_configuration_Report::INVALID; |
77 | $message = "PHP Version (${current}) is lower than ${min}."; |
78 | } |
79 | } elseif (empty($min) && !empty($max)) { |
80 | if (version_compare($current, $max, '<=')) { |
81 | $validity = common_configuration_Report::VALID; |
82 | $message = "PHP Version (${current}) is lesser than ${max}."; |
83 | } else { |
84 | $validity = common_configuration_Report::INVALID; |
85 | $message = "PHP Version (${current}) is greater than ${max}."; |
86 | } |
87 | } |
88 | |
89 | $returnValue = new common_configuration_Report($validity, $message, $this); |
90 | |
91 | |
92 | return $returnValue; |
93 | } |
94 | |
95 | /** |
96 | * Short description of method getValue |
97 | * |
98 | * @access public |
99 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
100 | * @return string |
101 | */ |
102 | public function getValue() |
103 | { |
104 | $returnValue = (string) ''; |
105 | |
106 | |
107 | $returnValue = phpversion(); |
108 | |
109 | |
110 | return (string) $returnValue; |
111 | } |
112 | |
113 | /** |
114 | * Short description of method __construct |
115 | * |
116 | * @access public |
117 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
118 | * @param string min |
119 | * @param string max |
120 | * @param boolean optional |
121 | * @return mixed |
122 | */ |
123 | public function __construct($min, $max, $optional = false) |
124 | { |
125 | |
126 | parent::__construct($min, $max, 'tao.configuration.phpruntime', $optional); |
127 | } |
128 | } |