MD5Hasher::make()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

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