Passed
Push — main ( 7270cc...9f13cb )
by Breno
01:52
created

is_empty()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 8
nc 8
nop 1
dl 0
loc 15
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace BrenoRoosevelt;
5
6
use Throwable;
7
use Traversable;
8
9
/**
10
 * @param array|Traversable $haystack
11
 * @return bool
12
 */
13
function is_empty($haystack): bool
14
{
15
    $tmp = $haystack;
16
    try {
17
        if (is_object($haystack)) {
18
            $tmp = clone $haystack;
19
        }
20
    } catch (Throwable $exception) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
21
    }
22
23
    foreach ($tmp as $item) {
24
        return false;
25
    }
26
27
    return true;
28
}
29