austinheap /
laravel-database-encryption
| 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
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 |