ClassUtils   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 19
rs 10
c 2
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A implements() 0 9 2
1
<?php
2
3
/**
4
 * This file is part of the Cervo package.
5
 *
6
 * Copyright (c) 2010-2019 Nevraxe inc. & Marc André Audet <[email protected]>.
7
 *
8
 * @package   Cervo
9
 * @author    Marc André Audet <[email protected]>
10
 * @copyright 2010 - 2019 Nevraxe inc. & Marc André Audet
11
 * @license   See LICENSE.md  MIT
12
 * @link      https://github.com/Nevraxe/Cervo
13
 * @since     5.0.0
14
 */
15
16
declare(strict_types=1);
17
18
namespace Cervo\Utils;
19
20
use ReflectionClass;
21
use ReflectionException;
22
23
24
/**
25
 * Cervo provider interface.
26
 *
27
 * @author Marc André Audet <[email protected]>
28
 */
29
final class ClassUtils
30
{
31
    /**
32
     * Verify if a Class implement an Interface.
33
     *
34
     * @param string $class The name of the Class that implements the Interface
35
     * @param string $interface The Interface to check against
36
     *
37
     * @return bool
38
     */
39
    public static function implements(string $class, string $interface): bool
40
    {
41
        try {
42
43
            $reflection = new ReflectionClass($class);
44
            return $reflection->implementsInterface($interface);
45
46
        } catch (ReflectionException $e) {
47
            return false;
48
        }
49
    }
50
}
51