ArrayCheck::hasNoElementAt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
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;
5
6
use PHPUnit\Framework\Assert;
7
8
/**
9
 * Class ArrayCheck
10
 *
11
 * @package Pitchart\Phlunit\Checks
12
 *
13
 * @author Julien VITTE <[email protected]>
14
 *
15
 * @implements FluentCheck<array>
16
 */
17
class ArrayCheck extends CollectionCheck implements FluentCheck
18
{
19
    /**
20
     * ArrayCheck constructor.
21
     *
22
     * @template T of array
23
     * @param array $collection
24
     */
25 41
    public function __construct(array $collection)
26
    {
27 41
        parent::__construct($collection);
28 41
    }
29
30
    /**
31
     * @param string|int $expected
32
     *
33
     * @return ArrayCheck
34
     */
35 2
    public function hasElementAt($expected): self
36
    {
37 2
        Assert::assertArrayHasKey($expected, (array) $this->value, $this->message);
38 2
        return $this;
39
    }
40
41
    /**
42
     * @param string|int $expected
43
     *
44
     * @return ArrayCheck
45
     */
46 2
    public function hasNoElementAt($expected): self
47
    {
48 2
        Assert::assertArrayNotHasKey($expected, (array) $this->value, $this->message);
49 2
        return $this;
50
    }
51
}
52