AssertionChain   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 3
b 0
f 0
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 7 3
A not() 0 4 1
1
<?php declare(strict_types=1);
2
namespace Behapi\Assert;
3
4
use Assert as Beberlei;
5
6
/**
7
 * PR needed while some PRs are not merged and released on upstream. :}
8
 *
9
 * @method AssertionChain empty(string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string is empty.
10
 *
11
 * @link https://github.com/beberlei/assert/pull/265
12
 */
13
class AssertionChain extends Beberlei\AssertionChain
14
{
15
    /**
16
     * Perform a negative assertion.
17
     *
18
     * @var bool
19
     */
20
    private $not = false;
21
22
    public function __call($methodName, $args): Beberlei\AssertionChain
23
    {
24
        if ($this->not && strtolower(substr($methodName, 0, 3)) !== 'not') {
25
            $methodName = "not{$methodName}";
26
        }
27
28
        return parent::__call($methodName, $args);
29
    }
30
31
    /**
32
     * Switch chain into negative mode.
33
     */
34
    public function not(): self
35
    {
36
        $this->not = true;
37
        return $this;
38
    }
39
}
40