FactoryTrait::transChoice()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 5
dl 0
loc 10
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace JBen87\ParsleyBundle\Constraint\Factory;
4
5
use Symfony\Contracts\Translation\TranslatorInterface;
6
7
trait FactoryTrait
8
{
9
    /**
10
     * @var TranslatorInterface
11
     */
12
    private $translator;
13
14
    /**
15
     * @param TranslatorInterface $translator
16
     *
17
     * @required
18
     */
19 33
    public function setTranslator(TranslatorInterface $translator): void
20
    {
21 33
        $this->translator = $translator;
22 33
    }
23
24
    /**
25
     * @param string $id
26
     * @param array $parameters
27
     * @param string $domain
28
     * @param string|null $locale
29
     *
30
     * @return string
31
     */
32 15
    private function trans(
33
        string $id,
34
        array $parameters = [],
35
        string $domain = 'validators',
36
        string $locale = null
37
    ): string {
38 15
        return $this->translator->trans($id, $parameters, $domain, $locale);
39
    }
40
41
    /**
42
     * @param string $id
43
     * @param int $number
44
     * @param array $parameters
45
     * @param string $domain
46
     * @param string|null $locale
47
     *
48
     * @return string
49
     */
50 3
    private function transChoice(
51
        string $id,
52
        int $number,
53
        array $parameters = [],
54
        string $domain = 'validators',
55
        string $locale = null
56
    ): string {
57 3
        $parameters['%count%'] = $number;
58
59 3
        return $this->translator->trans($id, $parameters, $domain, $locale);
60
    }
61
}
62