Test Failed
Push — master ( c62a52...9f7749 )
by Mehmet
03:07 queued 10s
created

functions.php ➔ convertCamelCase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace MerchantSafeUnipay;
5
6
function filter(array $filterKeys, array $arrayData)
7
{
8
    $filteredData = [];
9
    foreach ($arrayData as $key => $value) {
10
        if (in_array($key, $filterKeys, true)) {
11
            $filteredData[$key] = $value;
12
        }
13
    }
14
    return $filteredData;
15
}
16
17
function convertCamelCase(string $str, string $separator = '_')
18
{
19
    return preg_replace_callback(
20
        '/[A-Z]/',
21
        function ($match) use ($separator) {
22
            return $separator.strtolower($match[0]);
23
        },
24
        $str
25
    );
26
}
27