Passed
Push — master ( db1ea6...f2ea2d )
by Théo
03:06
created

Requirement   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 46
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getHelpText() 0 3 1
A getTestMessage() 0 3 1
A getIsFullfilledChecker() 0 3 1
A isFulfilled() 0 6 2
A __construct() 0 5 1
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