Completed
Push — master ( ed4971...ad2e84 )
by Tim
02:09
created

ArrayUtility::isEqualArray()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4888
c 0
b 0
f 0
cc 5
nc 5
nop 2
1
<?php
2
3
/**
4
 * ArrayUtility.
5
 */
6
declare(strict_types=1);
7
8
namespace HDNET\Calendarize\Utility;
9
10
use TYPO3\CMS\Core\Utility\MathUtility;
11
12
/**
13
 * ArrayUtility.
14
 */
15
class ArrayUtility
16
{
17
    /**
18
     * Check if the properties of the given arrays are equals.
19
     *
20
     * @param array $neededItem
21
     * @param array $currentItem
22
     *
23
     * @return bool
24
     */
25
    public static function isEqualArray(array $neededItem, array $currentItem)
26
    {
27
        foreach ($neededItem as $key => $value) {
28
            if (MathUtility::canBeInterpretedAsInteger($value)) {
29
                if ((int) $value !== (int) $currentItem[$key]) {
30
                    return false;
31
                }
32
            } elseif ((string) $value !== (string) $currentItem[$key]) {
33
                return false;
34
            }
35
        }
36
37
        return true;
38
    }
39
}
40