Completed
Push — master ( 2fef72...ca35b8 )
by Łukasz
23:27
created

UserPasswordValidationException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace eZ\Publish\Core\Base\Exceptions;
10
11
use Exception;
12
use eZ\Publish\Core\FieldType\ValidationError;
13
14
class UserPasswordValidationException extends InvalidArgumentException
15
{
16
    /**
17
     * Generates: "Argument '{$argumentName}' is invalid: Password doesn't match the following rules: {X}, {Y}, {Z}".
18
     *
19
     * @param string $argumentName
20
     * @param array $errors
21
     * @param Exception|null $previous
22
     */
23
    public function __construct(string $argumentName, array $errors, Exception $previous = null)
24
    {
25
        $rules = array_map(function (ValidationError $error) {
26
            return (string) $error->getTranslatableMessage();
27
        }, $errors);
28
29
        parent::__construct($argumentName, "Password doesn't match the following rules: " . implode(', ', $rules), $previous);
30
    }
31
}
32