Completed
Push — master ( e45d47...fbc4e2 )
by Dawid
03:25
created

AssertUtils   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 52
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 9

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isNotEmpty() 0 3 1
A isNumericOrNull() 0 3 2
A isAtLeastOneArgumentNotNull() 0 9 3
A hasNonStrings() 0 9 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiechu\SymfonyCommonsBundle\Utils;
6
7
class AssertUtils
8
{
9
    /**
10
     * @param iterable|string[] $elements
11
     *
12
     * @return bool
13
     */
14 24
    public static function hasNonStrings(iterable $elements): bool
15
    {
16 24
        foreach ($elements as $string) {
17 24
            if (!\is_string($string)) {
18 24
                return true;
19
            }
20
        }
21
22 24
        return false;
23
    }
24
25
    /**
26
     * @param string $string
27
     *
28
     * @return bool
29
     */
30 26
    public static function isNotEmpty(string $string): bool
31
    {
32 26
        return '' !== $string;
33
    }
34
35
    /**
36
     * @param null|string $string
37
     *
38
     * @return bool
39
     */
40 8
    public static function isNumericOrNull(?string $string): bool
41
    {
42 8
        return !(null !== $string && !is_numeric($string));
43
    }
44
45
    /**
46
     * @param null[]|string[] ...$arguments
47
     *
48
     * @return bool
49
     */
50 6
    public static function isAtLeastOneArgumentNotNull(?string ...$arguments): bool
51
    {
52 6
        foreach ($arguments as $argument) {
53 6
            if (null !== $argument) {
54 6
                return true;
55
            }
56
        }
57
58 1
        return false;
59
    }
60
}
61