SecretValidationTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateSecret() 0 6 3
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/2fa-library project.
5
 *
6
 * (c) 2amigOS! <http://2amigos.us/>
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 Da\TwoFA\Traits;
13
14
use Da\TwoFA\Exception\InvalidSecretKeyException;
15
use Da\TwoFA\Validator\SecretKeyValidator;
16
17
trait SecretValidationTrait
18
{
19
    /**
20
     * @var SecretKeyValidator
21
     */
22
    protected $secretKeyValidator;
23
24
    /**
25
     * @param string $value
26
     *
27
     * @throws InvalidSecretKeyException
28
     */
29
    public function validateSecret($value)
30
    {
31
        if ($this->secretKeyValidator instanceof SecretKeyValidator && !$this->secretKeyValidator->validate($value)) {
32
            throw new InvalidSecretKeyException($this->secretKeyValidator->getFailReason());
33
        }
34
    }
35
}
36