functions.php ➔ get_param_names()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 14
ccs 0
cts 7
cp 0
crap 6
rs 9.7998
c 0
b 0
f 0
1
<?php
2
/**
3
 * @project yandex-direct-client
4
 */
5
6
namespace Yandex\Direct;
7
8
/**
9
 * @param string $method
10
 * @return array
11
 * @throws \ReflectionException
12
 */
13
function get_param_names($method)
14
{
15
    list($class, $method) = explode('::', $method);
16
17
    $refParams = (new \ReflectionMethod($class, $method))->getParameters();
18
19
    $paramNames = [];
20
21
    foreach ($refParams as $parameter) {
22
        $paramNames[] = $parameter->name;
23
    }
24
25
    return $paramNames;
26
}
27
28
/**
29
 * @param array $params
30
 * @return array
31
 */
32
function filter_params(array $params)
33
{
34
    return array_filter($params, function ($value) {
35
        return !is_null($value);
36
    });
37
}
38