IsAssoc::isAssoc()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 3
eloc 4
c 1
b 1
f 0
nc 3
nop 1
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Wszetko Sitemap.
7
 *
8
 * (c) Paweł Kłopotek-Główczewski <[email protected]>
9
 *
10
 * This source file is subject to the MIT license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13
14
namespace Wszetko\Sitemap\Traits;
15
16
/**
17
 * Trait IsAssoc
18
 *
19
 * @package Wszetko\Sitemap\Traits
20
 */
21
trait IsAssoc
22
{
23
    /**
24
     * Check if array is associative.
25
     *
26
     * @param array $array
27
     *
28
     * @return bool
29
     */
30 4
    protected function isAssoc(array $array): bool
31
    {
32 4
        foreach (array_keys($array) as $key) {
33 4
            if (!is_integer($key)) {
34 4
                return true;
35
            }
36
        }
37
38 4
        return false;
39
    }
40
}
41