ArrayCheck   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 33
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasElementAt() 0 4 1
A hasNoElementAt() 0 4 1
A __construct() 0 3 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