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

AssertUtils::isNumericOrNull()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
c 0
b 0
f 0
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