UserNotFoundException::getCriteriaAsSting()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 9
loc 9
ccs 5
cts 5
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Security\Authentication\Exception;
6
7 View Code Duplication
final class UserNotFoundException 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 UserNotFoundException
13
     */
14 1
    public static function create(array $criteria): self
15
    {
16 1
        return new self(sprintf('user not found with criteria %s', self::getCriteriaAsSting($criteria)));
17
    }
18
19
    /**
20
     * @param array $criteria
21
     *
22
     * @return string
23
     */
24 1
    private static function getCriteriaAsSting(array $criteria): string
25
    {
26 1
        $criteriaString = '';
27 1
        foreach ($criteria as $key => $value) {
28 1
            $criteriaString .= $key.': '.$value.', ';
29
        }
30
31 1
        return substr($criteriaString, 0, -2);
32
    }
33
}
34