Passed
Push — master ( 8fffdc...3ef9a2 )
by Austin
03:09
created

src/EncryptionFacade.php (1 issue)

1
<?php
2
/**
3
 * src/EncryptionFacade.php.
4
 *
5
 * @author      Austin Heap <[email protected]>
6
 * @version     v0.2.0
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 84
    public static function getFacadeAccessor()
29
    {
30 84
        return 'DatabaseEncryption';
31
    }
32
33
    /**
34
     * Get the singleton of EncryptionHelper.
35
     *
36
     * @return EncryptionHelper
37
     */
38 26
    public static function getInstance()
39
    {
40 26
        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\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 21
    public static function __callStatic($method, $args)
53
    {
54 21
        $instance = static::getInstance();
55
56 21
        throw_if(! $instance, RuntimeException::class, 'A facade root has not been set.');
57 21
        throw_if(! method_exists($instance, $method), RuntimeException::class, 'Method "'.$method.'" does not exist on "'.get_class($instance).'".');
58
59 20
        return $instance->$method(...$args);
60
    }
61
}
62