Total Complexity | 4 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class Base62Driver implements DriverInterface |
||
10 | { |
||
11 | /** |
||
12 | * The Base62 instance. |
||
13 | * |
||
14 | * @var \Tuupola\Base62\GmpEncoder|\Tuupola\Base62\PhpEncoder |
||
15 | */ |
||
16 | protected $base62; |
||
17 | |||
18 | /** |
||
19 | * Create a new Base62 driver instance. |
||
20 | * |
||
21 | * @param array $config |
||
22 | */ |
||
23 | 12 | public function __construct(array $config = []) |
|
24 | { |
||
25 | 12 | $options = Arr::only($config, ['characters']); |
|
26 | |||
27 | 12 | $this->base62 = extension_loaded('gmp') |
|
28 | 12 | ? new GmpEncoder($options) : new PhpEncoder($options); |
|
29 | 6 | } |
|
30 | |||
31 | /** |
||
32 | * Encode the data. |
||
33 | * |
||
34 | * @param string $data |
||
35 | * @return string |
||
36 | */ |
||
37 | 8 | public function encode($data) |
|
38 | { |
||
39 | 8 | return $this->base62->encode($data); |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * Decode the data. |
||
44 | * |
||
45 | * @param string $data |
||
46 | * @return string |
||
47 | */ |
||
48 | 8 | public function decode($data) |
|
51 | } |
||
52 | } |
||
53 |