array_multiple_keys_exists()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the sauls/helpers package.
4
 *
5
 * @author    Saulius Vaičeliūnas <[email protected]>
6
 * @link      http://saulius.vaiceliunas.lt
7
 * @copyright 2018
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Sauls\Component\Helper;
14
15
use Sauls\Component\Helper\Exception\PropertyNotAccessibleException;
16
use Sauls\Component\Helper\Operation\ArrayOperation;
17
use Sauls\Component\Helper\Operation\Factory\OperationFactory;
18
19
function array_merge(array ...$arrays): array
20
{
21
    return \call_user_func_array(
22
        [
23 9
            OperationFactory::create(ArrayOperation\Merge::class),
24 9
            'execute',
25
        ],
26 9
        $arrays
27
    );
28
}
29
30
/**
31
 * @throws PropertyNotAccessibleException
32
 * @throws \Exception
33
 */
34
function array_get_value($array, $key, $default = null)
35
{
36 17
    return OperationFactory::create(ArrayOperation\GetValue::class)->execute($array, $key, $default);
0 ignored issues
show
Bug introduced by
The method execute() does not exist on Sauls\Component\Helper\Operation\Operation. It seems like you code against a sub-type of said class. However, the method does not exist in Sauls\Component\Helper\O...ation\ToObjectInterface or Sauls\Component\Helper\O...ArrayOperation\ToObject. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
    return OperationFactory::create(ArrayOperation\GetValue::class)->/** @scrutinizer ignore-call */ execute($array, $key, $default);
Loading history...
37
}
38
39
/**
40
 * @throws \Exception
41
 */
42
function array_set_value(array &$array, $key, $value): void
43
{
44 7
    OperationFactory::create(ArrayOperation\SetValue::class)->execute($array, $key, $value);
45 7
}
46
47
/**
48
 * @throws \Exception
49
 */
50
function array_remove_key(&$array, $key, $default = null)
51
{
52 8
    return OperationFactory::create(ArrayOperation\RemoveKey::class)->execute($array, $key, $default);
53
}
54
55
/**
56
 * @throws \Exception
57
 */
58
function array_key_exists($key, array $array): bool
59
{
60 10
    return OperationFactory::create(ArrayOperation\KeyExists::class)->execute($key, $array);
61
}
62
63
/**
64
 * @throws \Exception
65
 */
66
function array_remove_value(&$array, $value): array
67
{
68 3
    return OperationFactory::create(ArrayOperation\RemoveValue::class)->execute($array, $value);
69
}
70
71
/**
72
 * @throws \Exception
73
 */
74
function array_deep_search(array $array, $searchValue)
75
{
76 5
    return OperationFactory::create(ArrayOperation\DeepSearch::class)->execute($array, $searchValue);
77
}
78
79
/**
80
 * @throws \RuntimeException
81
 * @throws \Exception
82
 */
83
function array_flatten(array $array): array
84
{
85 5
    return OperationFactory::create(ArrayOperation\Flatten::class)->execute($array);
86
}
87
88
/**
89
 * @throws \Exception
90
 */
91
function array_multiple_keys_exists(array $keys, array $array): bool
92
{
93 1
    return OperationFactory::create(ArrayOperation\MultipleKeysExists::class)->execute($keys, $array);
94
}
95
96
/**
97
 * @throws \Exception
98
 */
99
function array_keys(array $array): array
100
{
101 1
    return OperationFactory::create(ArrayOperation\Keys::class)->execute($array);
102
}
103
104
/**
105
 * @throws \Exception
106
 */
107
function array_keys_with_value(array $array): array
108
{
109 1
    return OperationFactory::create(ArrayOperation\KeysWithValue::class)->execute($array);
110
}
111
112
/**
113
 * @throws \Exception
114
 */
115
function array_diff_key(... $arrays): array
116
{
117
    return \call_user_func_array(
118
        [
119 2
            OperationFactory::create(ArrayOperation\DiffKey::class),
120 2
            'execute',
121
        ],
122 2
        $arrays
123
    );
124
}
125
126
function array_key_childs_exist($key, array $array): bool
127
{
128 1
    return OperationFactory::create(ArrayOperation\KeyChildsExist::class)->execute($key, $array);
129
}
130