SecretGenerator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 16
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateRandomSecret() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the MesCryptoBundle package.
5
 *
6
 * (c) Francesco Cartenì <http://www.multimediaexperiencestudio.it/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Mes\Security\CryptoBundle\Utils;
13
14
/**
15
 * Class SecretGenerator.
16
 */
17
class SecretGenerator
18
{
19
    /**
20
     * Generates a random secret.
21
     *
22
     * @return string The randomly generated secret
23
     */
24 5
    public function generateRandomSecret()
25
    {
26 5
        if (function_exists('openssl_random_pseudo_bytes')) {
27 5
            return hash('sha1', openssl_random_pseudo_bytes(23));
28
        }
29
30
        return hash('sha1', uniqid(mt_rand(), true));
31
    }
32
}
33