ConstraintCheck::is()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
3
4
namespace Pitchart\Phlunit\Checks\Mixin;
5
6
use PHPUnit\Framework\Assert;
7
use PHPUnit\Framework\Constraint\Constraint;
8
use PHPUnit\Framework\Constraint\LogicalNot;
9
10
trait ConstraintCheck
11
{
12 1
    public function has(Constraint $constraint): self
13
    {
14 1
        Assert::assertThat($this->value, $constraint);
15 1
        $this->resetMessage();
0 ignored issues
show
Bug introduced by
It seems like resetMessage() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

15
        $this->/** @scrutinizer ignore-call */ 
16
               resetMessage();
Loading history...
16 1
        return $this;
17
    }
18
19 1
    public function is(Constraint $constraint): self
20
    {
21 1
        return $this->has($constraint);
22
    }
23
24 1
    public function hasNot(Constraint $constraint): self
25
    {
26 1
        Assert::assertThat($this->value, new LogicalNot($constraint));
27 1
        $this->resetMessage();
28 1
        return $this;
29
    }
30
31 1
    public function isNot(Constraint $constraint): self
32
    {
33 1
        return $this->hasNot($constraint);
34
    }
35
}
36