Tools   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
eloc 3
c 2
b 0
f 2
dl 0
loc 23
ccs 3
cts 3
cp 1
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
    /**
21
     * @psalm-suppress UnusedConstructor
22
     *
23
     * @codeCoverageIgnore
24
     */
25
    private function __construct()
26
    {
27
    }
28
29
    /**
30
     * Checks if the spl enum has been defined
31
     *
32
     * @param string $class Checks if the enum has been defined
33
     * @param boolean $autoload Whether to autoload if not already loaded.
34
     *
35
     * @return boolean Returns true if enum is a defined enum, false otherwise.
36
     */
37 1
    public static function isSplEnumExists(string $class, bool $autoload = true): bool
38
    {
39 1
        return \class_exists($class, $autoload)
40 1
            && \is_a($class, SplEnum::class, true);
41
    }
42
}
43