Passed
Push — master ( a9ce00...7fc17a )
by Timo
04:19
created

InterfaceHelper::getImplementations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 2
cts 2
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace hamburgscleanest\GuzzleAdvancedThrottle\Helpers;
4
5
/**
6
 * Class InterfaceHelper
7
 * @package hamburgscleanest\GuzzleAdvancedThrottle\src\Helpers
8
 */
9
class InterfaceHelper
10
{
11
12
    /**
13
     * Get every class that implements $interfaceName
14
     *
15
     * @param string $interfaceName
16
     * @return array
17
     */
18 5
    public static function getImplementations(string $interfaceName) : array
19
    {
20
        return \array_filter(\get_declared_classes(), function($className) use ($interfaceName)
21
        {
22 5
            return self::implementsInterface($className, $interfaceName);
23 5
        });
24
    }
25
26
    /**
27
     * Returns true|false if the $implementerClassName implements interface $interfaceName
28
     *
29
     * @param string $implementerClassName class name of the implementation class to test
30
     * @param string $interfaceName name of the interface that should be implemented
31
     * @return bool TRUE if the $implementerClassName implements $interfaceName, FALSE otherwise
32
     */
33 32
    public static function implementsInterface(string $implementerClassName, string $interfaceName) : bool
34
    {
35 32
        return \in_array($interfaceName, \class_implements($implementerClassName), true);
36
    }
37
}