| Total Complexity | 6 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | final class Requirement |
||
| 21 | { |
||
| 22 | private $checkIsFulfilled; |
||
| 23 | private $fulfilled; |
||
| 24 | private $testMessage; |
||
| 25 | private $helpText; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @param string $checkIsFulfilled Callable as a string (it will be evaluated with `eval()` returning a `bool` value telling whether the |
||
| 29 | * requirement is fulfilled or not. The condition is evaluated lazily. |
||
| 30 | * @param string $testMessage The message for testing the requirement |
||
| 31 | * @param string $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) |
||
| 32 | */ |
||
| 33 | public function __construct( |
||
| 34 | $checkIsFulfilled, |
||
| 35 | $testMessage, |
||
| 36 | $helpText |
||
| 37 | ) { |
||
| 38 | $this->checkIsFulfilled = $checkIsFulfilled; |
||
| 39 | $this->testMessage = $testMessage; |
||
| 40 | $this->helpText = $helpText; |
||
| 41 | } |
||
| 42 | |||
| 43 | public function isFulfilled() |
||
| 44 | { |
||
| 45 | if (null === $this->fulfilled) { |
||
| 46 | $this->fulfilled = eval($this->checkIsFulfilled); |
||
| 47 | } |
||
| 48 | |||
| 49 | return (bool) $this->fulfilled; // Cast to boolean, `(bool)` and `boolval()` are not available in PHP 5.3 |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return string |
||
| 54 | */ |
||
| 55 | public function getIsFullfilledChecker() |
||
| 56 | { |
||
| 57 | return $this->checkIsFulfilled; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return string |
||
| 62 | */ |
||
| 63 | public function getTestMessage() |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return string |
||
| 70 | */ |
||
| 71 | public function getHelpText() |
||
| 74 | } |
||
| 75 | } |
||
| 76 |