AbstractFacade::instance()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Lagdo\Facades;
4
5
/**
6
 * @template Service of object
7
 * @mixin Service
8
 */
9
abstract class AbstractFacade
10
{
11
    /**
12
     * Get the service identifier.
13
     *
14
     * @return string
15
     */
16
    abstract protected static function getServiceIdentifier(): string;
17
18
    /**
19
     * Get the service instance.
20
     *
21
     * @return Service
22
     */
23
    public static function instance(): mixed
24
    {
25
        return ContainerWrapper::getFacadeService(static::getServiceIdentifier());
26
    }
27
28
    /**
29
     * Call the service.
30
     *
31
     * @param string $method
32
     * @param array  $arguments
33
     *
34
     * @return mixed
35
     */
36
    public static function __callStatic(string $method, array $arguments): mixed
37
    {
38
        // Get the instance and call the method.
39
        return self::instance()->$method(...$arguments);
40
    }
41
}
42