IsMagic   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 28
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 3 1
A __callStatic() 0 3 1
A __call() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cerbero\Enum\Concerns;
6
7
use Cerbero\Enum\Enums;
8
9
/**
10
 * The trait to handle the magic methods of an enum.
11
 */
12
trait IsMagic
13
{
14
    /**
15
     * Handle the call to an inaccessible enum method.
16
     *
17
     * @param array<array-key, mixed> $arguments
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<array-key, mixed> at position 2 could not be parsed: Unknown type name 'array-key' at position 2 in array<array-key, mixed>.
Loading history...
18
     */
19 4
    public static function __callStatic(string $name, array $arguments): mixed
20
    {
21 4
        return Enums::handleStaticCall(self::class, $name, $arguments);
22
    }
23
24
    /**
25
     * Handle the call to an inaccessible case method.
26
     *
27
     * @param array<array-key, mixed> $arguments
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<array-key, mixed> at position 2 could not be parsed: Unknown type name 'array-key' at position 2 in array<array-key, mixed>.
Loading history...
28
     */
29 14
    public function __call(string $name, array $arguments): mixed
30
    {
31 14
        return Enums::handleCall($this, $name, $arguments);
32
    }
33
34
    /**
35
     * Handle the invocation of a case.
36
     */
37 2
    public function __invoke(mixed ...$arguments): mixed
38
    {
39 2
        return Enums::handleInvoke($this, ...$arguments);
40
    }
41
}
42