GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 3a3beb...943a46 )
by Ransford
04:49 queued 11s
created

RangeValidityCheck::isValid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Billing Boss
4
 *
5
 * @copyright 2018 Ransford Ako Okpoti
6
 * @license   Refer to the LICENSE distributed with this library
7
 * @link      https://github.com/ranskills/billing-boss-php
8
 */
9
10
namespace BillingBoss\Traits;
11
12
use BillingBoss\BillContext;
13
use BillingBoss\Exception\RangeException;
14
use BillingBoss\Expr;
15
use BillingBoss\RangeHelper;
16
17
/**
18
 * A trait to that implements isValid function for range-related interpreters
19
 *
20
 * @package BillingBoss
21
 * @author  Ransford Ako Okpoti <[email protected]>
22
 * @since   1.0.0
23
 */
24
trait RangeValidityCheck
25
{
26
    protected $ranges = [];
27
28
    /**
29
     * Validates the BillingContext#structure
30
     *
31
     * An interpreter that returns false if it can not match the structure of the
32
     * context.
33
     * True is returned if the structure is syntactically correct and contextually
34
     * it can be interpreted
35
     *
36
     * An exception is throw when structurally the notation/structure provided is
37
     * semantically valid but contextually cannot be interpreted
38
     *
39
     * @param BillContext $context The context to be validated
40
     * @return bool true if the context is validated, false otherwise
41
     * @throws RangeException
42
     */
43 12
    public function isValid(BillContext $context): bool
44
    {
45 12
        if (preg_match(sprintf('/%s/', Expr::RANGE), $context->getStructure()) === 0) {
46 5
            return false;
47
        }
48
49 7
        $this->ranges = RangeHelper::validate($context->getStructure());
50
51 5
        return count($this->ranges) > 0;
52
    }
53
}
54