/
PhpVersion.php
66 lines (58 loc) · 1.48 KB
/
PhpVersion.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace Concrete\Core\Install\Preconditions;
use Concrete\Core\Install\PreconditionInterface;
use Concrete\Core\Install\PreconditionResult;
class PhpVersion implements PreconditionInterface
{
/**
* The minimum PHP version.
*
* @var string
*/
const MINIMUM_PHP_VERSION = '5.5.9';
/**
* {@inheritdoc}
*
* @see PreconditionInterface::getName()
*/
public function getName()
{
return sprintf('PHP %s', static::MINIMUM_PHP_VERSION);
}
/**
* {@inheritdoc}
*
* @see PreconditionInterface::getUniqueIdentifier()
*/
public function getUniqueIdentifier()
{
return 'php_version';
}
/**
* {@inheritdoc}
*
* @see PreconditionInterface::isOptional()
*/
public function isOptional()
{
return false;
}
/**
* {@inheritdoc}
*
* @see PreconditionInterface::performCheck()
*/
public function performCheck()
{
$result = new PreconditionResult();
if (version_compare(PHP_VERSION, static::MINIMUM_PHP_VERSION) < 0) {
$result
->setState(PreconditionResult::STATE_FAILED)
->setMessage(t('concrete5 requires at least PHP version %1$s (you are running PHP version %2$s).', static::MINIMUM_PHP_VERSION, PHP_VERSION))
;
} else {
$result->setMessage(t('you are running PHP version %s', PHP_VERSION));
}
return $result;
}
}