Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
85.71% |
18 / 21 |
|
80.00% |
4 / 5 |
CRAP | |
0.00% |
0 / 1 |
| common_configuration_PHPINIValue | |
85.71% |
18 / 21 |
|
80.00% |
4 / 5 |
8.19 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| check | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
4 | |||
| getExpectedValue | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| setExpectedValue | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getValue | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| 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_PHPINIValue |
| 29 | * |
| 30 | * @access public |
| 31 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 32 | * @package generis |
| 33 | |
| 34 | */ |
| 35 | class common_configuration_PHPINIValue extends common_configuration_Component |
| 36 | { |
| 37 | // --- ASSOCIATIONS --- |
| 38 | |
| 39 | |
| 40 | // --- ATTRIBUTES --- |
| 41 | |
| 42 | /** |
| 43 | * Short description of attribute expectedValue |
| 44 | * |
| 45 | * @access private |
| 46 | * @var string |
| 47 | */ |
| 48 | private $expectedValue = ''; |
| 49 | |
| 50 | // --- OPERATIONS --- |
| 51 | |
| 52 | /** |
| 53 | * Short description of method __construct |
| 54 | * |
| 55 | * @access public |
| 56 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 57 | * @param string expectedValue |
| 58 | * @param string name |
| 59 | * @param boolean optional |
| 60 | * @return mixed |
| 61 | */ |
| 62 | public function __construct($expectedValue, $name = 'unknown', $optional = false) |
| 63 | { |
| 64 | |
| 65 | parent::__construct($name, $optional); |
| 66 | $this->setExpectedValue($expectedValue); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Short description of method check |
| 71 | * |
| 72 | * @access public |
| 73 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 74 | * @return common_configuration_Report |
| 75 | */ |
| 76 | public function check() |
| 77 | { |
| 78 | $returnValue = null; |
| 79 | |
| 80 | |
| 81 | $validity = null; |
| 82 | $name = $this->getName(); |
| 83 | if (($value = ini_get($name)) !== false) { |
| 84 | // The ini value exists for this name. |
| 85 | if ((($value == '') ? '0' : $value) == $this->getExpectedValue()) { |
| 86 | $validity = common_configuration_Report::VALID; |
| 87 | $message = "PHP Configuration Option '${name}' = '${value}' has an expected value."; |
| 88 | } else { |
| 89 | $validity = common_configuration_Report::INVALID; |
| 90 | $message = "PHP Configuration Option '${name}' = '${value}' has an unexpected value."; |
| 91 | } |
| 92 | } else { |
| 93 | // Unknown ini value name. |
| 94 | $validity = common_configuration_Report::UNKNOWN; |
| 95 | $message = "PHP Configuration Option '${name}' is unknown."; |
| 96 | } |
| 97 | |
| 98 | $returnValue = new common_configuration_Report($validity, $message, $this); |
| 99 | |
| 100 | |
| 101 | return $returnValue; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Short description of method getExpectedValue |
| 106 | * |
| 107 | * @access public |
| 108 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 109 | * @return string |
| 110 | */ |
| 111 | public function getExpectedValue() |
| 112 | { |
| 113 | $returnValue = (string) ''; |
| 114 | |
| 115 | |
| 116 | return $this->expectedValue; |
| 117 | |
| 118 | |
| 119 | return (string) $returnValue; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Short description of method setExpectedValue |
| 124 | * |
| 125 | * @access public |
| 126 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 127 | * @param string expectedValue |
| 128 | * @return mixed |
| 129 | */ |
| 130 | public function setExpectedValue($expectedValue) |
| 131 | { |
| 132 | |
| 133 | $this->expectedValue = $expectedValue; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Short description of method getValue |
| 138 | * |
| 139 | * @access public |
| 140 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 141 | * @return string |
| 142 | */ |
| 143 | public function getValue() |
| 144 | { |
| 145 | $returnValue = (string) ''; |
| 146 | |
| 147 | |
| 148 | $returnValue = ini_get($this->getName()); |
| 149 | |
| 150 | |
| 151 | return (string) $returnValue; |
| 152 | } |
| 153 | } |