hashid_decode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 2
crap 1
1
<?php
2
3
if (! function_exists('hashid')) {
4
    /**
5
     * Get a hashid connection instance.
6
     *
7
     * @param  string|null  $name
8
     * @return \ElfSundae\Laravel\Hashid\DriverInterface
9
     */
10
    function hashid($name = null)
11
    {
12 12
        return app('hashid')->connection($name);
13
    }
14
}
15
16
if (! function_exists('hashid_encode')) {
17
    /**
18
     * Encode the given data using hashid.
19
     *
20
     * @param  mixed  $data
21
     * @param  string|null  $name
22
     * @return mixed
23
     */
24
    function hashid_encode($data, $name = null)
25
    {
26 4
        return hashid($name)->encode($data);
27
    }
28
}
29
30
if (! function_exists('hashid_decode')) {
31
    /**
32
     * Decode the given data using hashid.
33
     *
34
     * @param  mixed  $data
35
     * @param  string|null  $name
36
     * @return mixed
37
     */
38
    function hashid_decode($data, $name = null)
39
    {
40 4
        return hashid($name)->decode($data);
41
    }
42
}
43