Code Duplication    Length = 27-27 lines in 2 locations

src/Authentication/Exception/InvalidPasswordException.php 1 location

@@ 7-33 (lines=27) @@
4
5
namespace Chubbyphp\Security\Authentication\Exception;
6
7
final class InvalidPasswordException extends \RuntimeException implements AuthenticationExceptionInterface
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

src/Authentication/Exception/UserNotFoundException.php 1 location

@@ 7-33 (lines=27) @@
4
5
namespace Chubbyphp\Security\Authentication\Exception;
6
7
final class UserNotFoundException extends \RuntimeException implements AuthenticationExceptionInterface
8
{
9
    /**
10
     * @param array $criteria
11
     *
12
     * @return UserNotFoundException
13
     */
14
    public static function create(array $criteria): self
15
    {
16
        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
    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