1 | <?php namespace Arcanedev\Hasher; |
||
13 | class HashManager extends Manager implements HashManagerContract |
||
14 | { |
||
15 | /* ----------------------------------------------------------------- |
||
16 | | Properties |
||
17 | | ----------------------------------------------------------------- |
||
18 | */ |
||
19 | |||
20 | /** |
||
21 | * The driver option. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $option; |
||
26 | |||
27 | /* ----------------------------------------------------------------- |
||
28 | | Constructor |
||
29 | | ----------------------------------------------------------------- |
||
30 | */ |
||
31 | |||
32 | /** |
||
33 | * HashManager constructor. |
||
34 | * |
||
35 | * @param \Illuminate\Contracts\Container\Container $container |
||
36 | */ |
||
37 | 20 | public function __construct(Container $container) |
|
43 | |||
44 | /* ----------------------------------------------------------------- |
||
45 | | Getters & Setters |
||
46 | | ----------------------------------------------------------------- |
||
47 | */ |
||
48 | |||
49 | /** |
||
50 | * Get the default driver name. |
||
51 | * |
||
52 | * @return string |
||
53 | */ |
||
54 | 10 | public function getDefaultDriver() |
|
58 | |||
59 | /** |
||
60 | * Get the default driver connection. |
||
61 | * |
||
62 | * @return string |
||
63 | */ |
||
64 | 20 | public function getDefaultOption() |
|
68 | |||
69 | /** |
||
70 | * Set the hasher option. |
||
71 | * |
||
72 | * @param string $option |
||
73 | * |
||
74 | * @return \Arcanedev\Hasher\HashManager |
||
75 | */ |
||
76 | 8 | public function option($option = null) |
|
85 | |||
86 | /* ----------------------------------------------------------------- |
||
87 | | Main Methods |
||
88 | | ----------------------------------------------------------------- |
||
89 | */ |
||
90 | |||
91 | /** |
||
92 | * Get a driver instance. |
||
93 | * |
||
94 | * @param string $driver |
||
95 | * @param string|null $option |
||
96 | * |
||
97 | * @return \Arcanedev\Hasher\Contracts\HashDriver |
||
98 | */ |
||
99 | 4 | public function with($option = null, $driver = null) |
|
103 | |||
104 | /** |
||
105 | * Get a driver instance. |
||
106 | * |
||
107 | * @param string $driver |
||
108 | * |
||
109 | * @return \Arcanedev\Hasher\Contracts\HashDriver |
||
110 | */ |
||
111 | 12 | public function driver($driver = null) |
|
115 | |||
116 | /** |
||
117 | * Build all hash drivers. |
||
118 | */ |
||
119 | 20 | private function buildDrivers(): void |
|
125 | |||
126 | /** |
||
127 | * Build the driver. |
||
128 | * |
||
129 | * @param string $name |
||
130 | * @param array $params |
||
131 | */ |
||
132 | 20 | private function buildDriver(string $name, array $params): void |
|
138 | |||
139 | /** |
||
140 | * Encode the value. |
||
141 | * |
||
142 | * @param mixed $value |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | 2 | public function encode($value) |
|
150 | |||
151 | /** |
||
152 | * Decode the hashed value. |
||
153 | * |
||
154 | * @param string $hashed |
||
155 | * |
||
156 | * @return mixed |
||
157 | */ |
||
158 | 2 | public function decode($hashed) |
|
162 | |||
163 | /* ----------------------------------------------------------------- |
||
164 | | Other Methods |
||
165 | | ----------------------------------------------------------------- |
||
166 | */ |
||
167 | |||
168 | /** |
||
169 | * Get the hasher config. |
||
170 | * |
||
171 | * @param string $name |
||
172 | * @param mixed|null $default |
||
173 | * |
||
174 | * @return mixed |
||
175 | */ |
||
176 | 20 | protected function config(string $name, $default = null) |
|
180 | } |
||
181 |