AssertionChain::not()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 2
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
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