ArrayHelpersTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 23
c 2
b 0
f 0
dl 0
loc 54
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A stringArrayContainsStringValidValues() 0 37 1
A testInclusion() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\BackwardCompatibility\Support;
6
7
use PHPUnit\Framework\TestCase;
8
use Roave\BackwardCompatibility\Support\ArrayHelpers;
9
10
/**
11
 * @covers \Roave\BackwardCompatibility\Support\ArrayHelpers
12
 */
13
final class ArrayHelpersTest extends TestCase
14
{
15
    /**
16
     * @param string[] $array
17
     *
18
     * @dataProvider stringArrayContainsStringValidValues
19
     */
20
    public function testInclusion(string $value, array $array, bool $expected) : void
21
    {
22
        self::assertSame($expected, ArrayHelpers::stringArrayContainsString($value, $array));
23
    }
24
25
    /**
26
     * @return array<int, array<int, string|array<int, string>|bool>>
27
     *
28
     * @psalm-return array<int, array{0: string, 1: list<string>, 2: bool}>
29
     */
30
    public function stringArrayContainsStringValidValues() : array
31
    {
32
        return [
33
            [
34
                '',
35
                [],
36
                false,
37
            ],
38
            [
39
                '',
40
                [''],
41
                true,
42
            ],
43
            [
44
                '0',
45
                [''],
46
                false,
47
            ],
48
            [
49
                '',
50
                ['0'],
51
                false,
52
            ],
53
            [
54
                'foo',
55
                ['foo', 'bar', 'baz'],
56
                true,
57
            ],
58
            [
59
                'foo',
60
                ['bar', 'baz'],
61
                false,
62
            ],
63
            [
64
                'foo',
65
                ['foo', 'foo', 'foo'],
66
                true,
67
            ],
68
        ];
69
    }
70
}
71