Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#678)
by Henrique
03:27
created

ArrayTranslator::translate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Respect\Validation\Message;
13
14
/**
15
 * Uses a key value array to translate messages.
16
 *
17
 * @author Henrique Moody <[email protected]>
18
 *
19
 * @since 2.0.0
20
 */
21
final class ArrayTranslator implements Translator
22
{
23
    /**
24
     * @var array
25
     */
26
    private $messages = [];
27
28
    /**
29
     * Initializes the translator.
30
     *
31
     * @param array $messages Key value array with the messages
32
     */
33
    public function __construct(array $messages)
34
    {
35
        $this->messages = $messages;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function translate(string $message): string
42
    {
43
        if (array_key_exists($message, $this->messages)) {
44
            $message = $this->messages[$message];
45
        }
46
47
        return $message;
48
    }
49
}
50