Completed
Push — master ( 67ec2b...d15b3f )
by Dominik
02:51
created

UserNotFoundException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A getCriteriaAsSting() 0 9 2
1
<?php
2
3
namespace Chubbyphp\Security\Authentication\Exception;
4
5
final class UserNotFoundException extends \RuntimeException implements AuthenticationExceptionInterface
6
{
7
    /**
8
     * @param array $criteria
9
     *
10
     * @return UserNotFoundException
11
     */
12
    public static function create(array $criteria): self
13
    {
14
        return new self(sprintf('User not found with criteria %s', self::getCriteriaAsSting($criteria)));
15
    }
16
17
    /**
18
     * @param array $criteria
19
     *
20
     * @return string
21
     */
22
    private static function getCriteriaAsSting(array $criteria): string
23
    {
24
        $criteriaString = '';
25
        foreach ($criteria as $key => $value) {
26
            $criteriaString .= $key.': '.$value.', ';
27
        }
28
29
        return substr($criteriaString, 0, -2);
30
    }
31
}
32