MyMD5Hasher::make()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
1
<?php
2
3
4
namespace Yangwendaxia\Hasher;
5
6
7
use function hash;
8
9
/**
10
 * Class MyMD5Hasher
11
 * @package Yangwendaxia\Hasher
12
 */
13
class MyMD5Hasher
14
{
15
    /**
16
     * @param $value
17
     * @param array $options
18
     * @return string
19
     */
20
    public function make($value, array $options = [])
21
    {
22
        $salt = isset($options['salt']) ? $options['salt'] :'';
23
24
        return hash('md5',$value.$salt);
25
    }
26
27
    /**
28
     * @param $value
29
     * @param $hashValue
30
     * @param array $options
31
     * @return bool
32
     */
33
    public function check($value, $hashValue, array $options = [])
34
    {
35
        $salt = isset($options['salt']) ? $options['salt'] : '';
36
37
        return hash('md5', $value.$salt) === $hashValue;
38
    }
39
40
}
41