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   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 29
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A translate() 0 8 2
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