ArrayHelpers   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 13
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A stringArrayContainsString() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\BackwardCompatibility\Support;
6
7
use InvalidArgumentException;
8
use function in_array;
9
10
/**
11
 * @internal this is a support class of this library, and should NOT be used outside of it
12
 */
13
final class ArrayHelpers
14
{
15
    /**
16
     * Yes, this is just a very pedantic version of `in_array()`, written to avoid mutations and
17
     * designed to throw an exception if `$arrayOfStrings` is not a `string[]` as requested.
18
     *
19
     * @param string[] $arrayOfStrings
20
     *
21
     * @throws InvalidArgumentException
22
     */
23
    public static function stringArrayContainsString(string $value, array $arrayOfStrings) : bool
24
    {
25
        return in_array($value, $arrayOfStrings);
26
    }
27
}
28