Passed
Push — feature/second-release ( 6a86fe...3a565d )
by Andrea Marco
02:34
created

IsMagic   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 24
ccs 2
cts 6
cp 0.3333
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
namespace Cerbero\LaravelEnum\Concerns;
4
5
use Cerbero\LaravelEnum\Enums;
6
7
/**
8
 * The trait to handle the magic methods of an enum.
9
 */
10
trait IsMagic
11
{
12
    /**
13
     * Handle the call to an inaccessible enum method.
14
     */
15
    public static function __callStatic(string $name, array $arguments): mixed
16
    {
17
        return Enums::handleStaticCall(self::class, $name, $arguments);
18
    }
19
20
    /**
21
     * Handle the call to an inaccessible case method.
22
     */
23 4
    public function __call(string $name, array $arguments): mixed
24
    {
25 4
        return Enums::handleCall($this, $name, $arguments);
26
    }
27
28
    /**
29
     * Handle the invocation of a case.
30
     */
31
    public function __invoke(mixed ...$arguments): mixed
32
    {
33
        return Enums::handleInvoke($this, ...$arguments);
34
    }
35
}
36