1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the box project. |
5
|
|
|
* |
6
|
|
|
* (c) Kevin Herrera <[email protected]> |
7
|
|
|
* Théo Fidry <[email protected]> |
8
|
|
|
* |
9
|
|
|
* This source file is subject to the MIT license that is bundled |
10
|
|
|
* with this source code in the file LICENSE. |
11
|
|
|
*/ |
12
|
|
|
namespace _HumbugBox5addf3ce683e7\KevinGH\RequirementChecker; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* The code in this file must be PHP 5.3+ compatible as is used to know if the application can be run. |
16
|
|
|
* |
17
|
|
|
* @private |
18
|
|
|
*/ |
19
|
|
|
final class Requirement |
20
|
|
|
{ |
21
|
|
|
private $checkIsFulfilled; |
22
|
|
|
private $fulfilled; |
23
|
|
|
private $testMessage; |
24
|
|
|
private $helpText; |
25
|
|
|
/** |
26
|
|
|
* @param string $checkIsFulfilled Callable as a string (it will be evaluated with `eval()` returning a `bool` value telling whether the |
27
|
|
|
* requirement is fulfilled or not. The condition is evaluated lazily. |
28
|
|
|
* @param string $testMessage The message for testing the requirement |
29
|
|
|
* @param string $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) |
30
|
|
|
*/ |
31
|
|
|
public function __construct($checkIsFulfilled, $testMessage, $helpText) |
32
|
|
|
{ |
33
|
|
|
$this->checkIsFulfilled = $checkIsFulfilled; |
34
|
|
|
$this->testMessage = $testMessage; |
35
|
|
|
$this->helpText = $helpText; |
36
|
|
|
} |
37
|
|
|
public function isFulfilled() |
38
|
|
|
{ |
39
|
|
|
if (null === $this->fulfilled) { |
40
|
|
|
$this->fulfilled = eval($this->checkIsFulfilled); |
41
|
|
|
} |
42
|
|
|
return (bool) $this->fulfilled; |
43
|
|
|
// Cast to boolean, `(bool)` and `boolval()` are not available in PHP 5.3 |
44
|
|
|
} |
45
|
|
|
/** |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
public function getIsFullfilledChecker() |
49
|
|
|
{ |
50
|
|
|
return $this->checkIsFulfilled; |
51
|
|
|
} |
52
|
|
|
/** |
53
|
|
|
* @return string |
54
|
|
|
*/ |
55
|
|
|
public function getTestMessage() |
56
|
|
|
{ |
57
|
|
|
return $this->testMessage; |
58
|
|
|
} |
59
|
|
|
/** |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
|
|
public function getHelpText() |
63
|
|
|
{ |
64
|
|
|
return $this->helpText; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|