EncryptionFacade   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 39
rs 10
ccs 9
cts 9
cp 1
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 3 1
A getFacadeAccessor() 0 3 1
A __callStatic() 0 8 1
1
<?php
2
/**
3
 * src/EncryptionFacade.php.
4
 *
5
 * @author      Austin Heap <[email protected]>
6
 * @version     v0.2.1
7
 */
8
declare(strict_types=1);
9
10
namespace AustinHeap\Database\Encryption;
11
12
use RuntimeException;
13
14
/**
15
 * EncryptionFacade.
16
 *
17
 * @link        https://github.com/austinheap/laravel-database-encryption
18
 * @link        https://packagist.org/packages/austinheap/laravel-database-encryption
19
 * @link        https://austinheap.github.io/laravel-database-encryption/classes/AustinHeap.Database.Encryption.EncryptionFacade.html
20
 */
21
class EncryptionFacade extends \Illuminate\Support\Facades\Facade
22
{
23
    /**
24
     * Get the registered name of the component.
25
     *
26
     * @return string
27
     */
28 86
    public static function getFacadeAccessor()
29
    {
30 86
        return 'DatabaseEncryption';
31
    }
32
33
    /**
34
     * Get the singleton of EncryptionHelper.
35
     *
36
     * @return EncryptionHelper
37
     */
38 28
    public static function getInstance()
39
    {
40 28
        return app(self::getFacadeAccessor());
0 ignored issues
show
Bug Best Practice introduced by
The expression return app(self::getFacadeAccessor()) also could return the type Illuminate\Contracts\Foundation\Application which is incompatible with the documented return type AustinHeap\Database\Encryption\EncryptionHelper.
Loading history...
41
    }
42
43
    /**
44
     * Handle dynamic, static calls to the object.
45
     *
46
     * @param  string $method
47
     * @param  array  $args
48
     *
49
     * @return mixed
50
     * @throws \RuntimeException
51
     */
52 23
    public static function __callStatic($method, $args)
53
    {
54 23
        $instance = static::getInstance();
55
56 23
        throw_if(! $instance, RuntimeException::class, 'A facade root has not been set.');
57 23
        throw_if(! method_exists($instance, $method), RuntimeException::class, 'Method "'.$method.'" does not exist on "'.get_class($instance).'".');
58
59 22
        return $instance->$method(...$args);
60
    }
61
}
62