ZxcvbnFactory::createZxcvbn()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 2
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Createnl\ZxcvbnBundle;
5
6
use Symfony\Contracts\Translation\TranslatorInterface;
7
use ZxcvbnPhp\Matchers\MatchInterface;
8
use ZxcvbnPhp\Zxcvbn;
9
10
class ZxcvbnFactory implements ZxcvbnFactoryInterface
11
{
12
    /**
13
     * @var MatchInterface[]
14
     */
15
    private $additionalMatchers;
16
    /**
17
     * @var TranslatorInterface
18
     */
19
    private $translator;
20
21 1
    public function __construct(iterable $additionalMatchers, TranslatorInterface $translator)
22
    {
23 1
        $this->additionalMatchers = $additionalMatchers;
0 ignored issues
show
Documentation Bug introduced by
It seems like $additionalMatchers of type iterable is incompatible with the declared type ZxcvbnPhp\Matchers\MatchInterface[] of property $additionalMatchers.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
24 1
        $this->translator = $translator;
25 1
    }
26
27 1
    public function createZxcvbn(): Zxcvbn
28
    {
29 1
        $zxcvn = new ZxcvbnTranslation(
30 1
            new Zxcvbn(),
31 1
            $this->translator
32
        );
33
34 1
        foreach ($this->additionalMatchers as $matcher) {
35 1
            $zxcvn->addMatcher(get_class($matcher));
36
        }
37
38 1
        return $zxcvn;
39
    }
40
}
41