GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( cb7f05...c88989 )
by Maximilian
09:13
created

PHPPasswordHasher   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 40
ccs 8
cts 10
cp 0.8
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A generateHash() 0 4 1
A compareWith() 0 4 1
1
<?php
2
3
namespace Ma27\ApiKeyAuthenticationBundle\Service\Password;
4
5
/**
6
 * Concrete hasher that uses the php 5.5 api.
7
 */
8
class PHPPasswordHasher implements PasswordHasherInterface
9
{
10
    /**
11
     * @var int
12
     */
13
    private $cost;
14
15
    /**
16
     * Constructor.
17
     *
18
     * @param int $cost
19
     */
20 1
    public function __construct($cost = 12)
21
    {
22 1
        if (!function_exists('password_hash')) {
23
            throw new \RuntimeException(
24
                'In order to use this strategy please install the package "ircmaxell/password-compat" '.
25
                'or upgrade your php version to 5.5 or higher!'
26
            );
27
        }
28
29 1
        $this->cost = (int) $cost;
30 1
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 1
    public function generateHash($password)
36
    {
37 1
        return password_hash($password, PASSWORD_BCRYPT, array('cost' => $this->cost));
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 1
    public function compareWith($password, $raw)
44
    {
45 1
        return password_verify($raw, $password);
46
    }
47
}
48