MD5Hasher   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A make() 0 5 1
A check() 0 5 1
1
<?php
2
3
namespace Zhouxiaoshuai\Hasher;
4
5
/**
6
 * Class MD5Hasher
7
 * @package Zhouxiaoshuai\Hasher
8
 */
9
class MD5Hasher
10
{
11
    /**
12
     * @param $value
13
     * @param array $options
14
     * @return string
15
     */
16
    public function make($value, array $options = [])
17
    {
18
        $salt = $options['salt'] ?? '';
19
20
        return hash('md5', $value . $salt);
21
    }
22
23
    /**
24
     * @param $value
25
     * @param $hashValue
26
     * @param array $options
27
     * @return bool
28
     */
29
    public function check($value, $hashValue, array $options = [])
30
    {
31
        $salt = $options['salt'] ?? '';
32
33
        return hash('md5', $value . $salt) === $hashValue;
34
    }
35
}