MD5Hasher::make()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
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
}