Completed
Push — master ( 56f862...ea15ab )
by Dominik
03:39
created

InvalidPasswordException::getCriteriaAsSting()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Security\Authentication\Exception;
6
7 View Code Duplication
final class InvalidPasswordException extends \RuntimeException implements AuthenticationExceptionInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /**
10
     * @param array $criteria
11
     *
12
     * @return InvalidPasswordException
13
     */
14
    public static function create(array $criteria): self
15
    {
16
        return new self(sprintf('invalid password for user with criteria %s', self::getCriteriaAsSting($criteria)));
17
    }
18
19
    /**
20
     * @param array $criteria
21
     *
22
     * @return string
23
     */
24
    private static function getCriteriaAsSting(array $criteria): string
25
    {
26
        $criteriaString = '';
27
        foreach ($criteria as $key => $value) {
28
            $criteriaString .= $key.': '.$value.', ';
29
        }
30
31
        return substr($criteriaString, 0, -2);
32
    }
33
}
34