| @@ 170-204 (lines=35) @@ | ||
| 167 | * | |
| 168 | * @return string|boolean The version number on success or boolean false on failure. | |
| 169 | */ | |
| 170 | private function checkCMSVersion(string $version) | |
| 171 | 	{ | |
| 172 | $version = $this->validateVersionNumber($version); | |
| 173 | ||
| 174 | // If the version number is invalid, don't go any further | |
| 175 | if ($version === false) | |
| 176 | 		{ | |
| 177 | return false; | |
| 178 | } | |
| 179 | ||
| 180 | // Joomla only uses major.minor.patch so everything else is invalid | |
| 181 | 		$explodedVersion = explode('.', $version); | |
| 182 | ||
| 183 | if (\count($explodedVersion) > 3) | |
| 184 | 		{ | |
| 185 | return false; | |
| 186 | } | |
| 187 | ||
| 188 | try | |
| 189 | 		{ | |
| 190 | 			$validVersions = json_decode($this->filesystem->read('joomla.json'), true); | |
| 191 | } | |
| 192 | catch (FileNotFoundException $exception) | |
| 193 | 		{ | |
| 194 | 			throw new \RuntimeException('Missing Joomla! release listing', 500, $exception); | |
| 195 | } | |
| 196 | ||
| 197 | // Check that the version is in our valid release list | |
| 198 | if (!\in_array($version, $validVersions)) | |
| 199 | 		{ | |
| 200 | return false; | |
| 201 | } | |
| 202 | ||
| 203 | return $version; | |
| 204 | } | |
| 205 | ||
| 206 | /** | |
| 207 | * Check the database type | |
| @@ 230-264 (lines=35) @@ | ||
| 227 | * | |
| 228 | * @return string|boolean The version number on success or boolean false on failure. | |
| 229 | */ | |
| 230 | private function checkPHPVersion(string $version) | |
| 231 | 	{ | |
| 232 | $version = $this->validateVersionNumber($version); | |
| 233 | ||
| 234 | // If the version number is invalid, don't go any further | |
| 235 | if ($version === false) | |
| 236 | 		{ | |
| 237 | return false; | |
| 238 | } | |
| 239 | ||
| 240 | // We only track versions based on major.minor.patch so everything else is invalid | |
| 241 | 		$explodedVersion = explode('.', $version); | |
| 242 | ||
| 243 | if (\count($explodedVersion) > 3) | |
| 244 | 		{ | |
| 245 | return false; | |
| 246 | } | |
| 247 | ||
| 248 | try | |
| 249 | 		{ | |
| 250 | 			$validVersions = json_decode($this->filesystem->read('php.json'), true); | |
| 251 | } | |
| 252 | catch (FileNotFoundException $exception) | |
| 253 | 		{ | |
| 254 | 			throw new \RuntimeException('Missing PHP release listing', 500, $exception); | |
| 255 | } | |
| 256 | ||
| 257 | // Check that the version is in our valid release list | |
| 258 | if (!\in_array($version, $validVersions)) | |
| 259 | 		{ | |
| 260 | return false; | |
| 261 | } | |
| 262 | ||
| 263 | return $version; | |
| 264 | } | |
| 265 | } | |
| 266 | ||