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

ArrayUtility   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A isEqualArray() 0 14 5
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