Test Failed
Push — 7.x ( bea7e1...2b11c5 )
by Adrien
08:51
created

Tools   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
c 1
b 0
f 1
dl 0
loc 18
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A isSplEnumExists() 0 4 2
1
<?php
2
3
/**
4
 * Part of SplTypes package.
5
 *
6
 * (c) Adrien Loyant <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Ducks\Component\SplTypes\Util;
15
16
use Ducks\Component\SplTypes\SplEnum;
17
18
final class Tools
19
{
20
    private function __construct()
21
    {
22
    }
23
24
    /**
25
     * Checks if the spl enum has been defined
26
     *
27
     * @param string $enum Checks if the enum has been defined
28
     * @param boolean $autoload Whether to autoload if not already loaded.
29
     *
30
     * @return boolean Returns true if enum is a defined enum, false otherwise.
31
     */
32
    public static function isSplEnumExists(string $class, bool $autoload = true): bool
33
    {
34
        return \class_exists($class, $autoload)
35
            && \is_a($class, SplEnum::class, true);
36
    }
37
}
38