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

CryptPasswordHasher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 28
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A generateHash() 0 4 1
A compareWith() 0 4 1
A generateSalt() 0 4 1
1
<?php
2
3
namespace Ma27\ApiKeyAuthenticationBundle\Service\Password;
4
5
/**
6
 * Hasher which uses the crypt algorithm.
7
 */
8
class CryptPasswordHasher implements PasswordHasherInterface
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13 15
    public function generateHash($password)
14
    {
15 15
        return crypt($password, sprintf('$6$rounds=3000$%s$', $this->generateSalt()));
16
    }
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 12
    public function compareWith($password, $raw)
22
    {
23 12
        return crypt($raw, $password) === $password;
24
    }
25
26
    /**
27
     * Generates a salt using the openssl API.
28
     *
29
     * @return string
30
     */
31 15
    protected function generateSalt()
32
    {
33 15
        return bin2hex(openssl_random_pseudo_bytes(10));
34
    }
35
}
36