Test Failed
Pull Request — main (#59)
by Dimitri
06:14
created

BaseHandler::check()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 7
ccs 0
cts 2
cp 0
crap 6
rs 10
1
<?php
2
3
/**
4
 * This file is part of Blitz PHP framework.
5
 *
6
 * (c) 2022 Dimitri Sitchet Tomkeu <[email protected]>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace BlitzPHP\Security\Hashing\Handlers;
13
14
use BlitzPHP\Contracts\Security\HasherInterface;
15
16
/**
17
 * Gestionnaire de hashage de base
18
 *
19
 * @credit <a href="http://www.laravel.com">Laravel 11 - \Illuminate\Hashing\AbstractHasher</a>
20
 */
21
abstract class BaseHandler implements HasherInterface
22
{
23
    /**
24
     * {@inheritDoc}
25
     */
26
    public function info(string $hashedValue): array
27
    {
28
        return password_get_info($hashedValue);
0 ignored issues
show
Bug Best Practice introduced by
The expression return password_get_info($hashedValue) could return the type null which is incompatible with the type-hinted return array. Consider adding an additional type-check to rule them out.
Loading history...
29
    }
30
31
    /**
32
     * {@inheritDoc}
33
     */
34
    public function check(string $value, string $hashedValue, array $options = []): bool
35
    {
36
        if ($hashedValue === '') {
37
            return false;
38
        }
39
40
        return password_verify($value, $hashedValue);
41
    }
42
}
43