StubTranslator::trans()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\AdminBundle\Tests\Fixtures;
15
16
use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface;
17
use Symfony\Contracts\Translation\TranslatorInterface;
18
19
if (interface_exists(TranslatorInterface::class)) {
20
    final class StubTranslator implements TranslatorInterface
21
    {
22
        public function trans($id, array $parameters = [], $domain = null, $locale = null): string
23
        {
24
            return '[trans]'.strtr($id, $parameters).'[/trans]';
25
        }
26
    }
27
} else {
28
    final class StubTranslator implements LegacyTranslatorInterface
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type Sonata\AdminBundle\Tests\Fixtures\StubTranslator has been defined more than once; this definition is ignored, only the first definition in this file (L20-26) is considered.

This check looks for classes that have been defined more than once in the same file.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
Deprecated Code introduced by
The interface Symfony\Component\Translation\TranslatorInterface has been deprecated with message: since Symfony 4.2, use Symfony\Contracts\Translation\TranslatorInterface instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
29
    {
30
        public function trans($id, array $parameters = [], $domain = null, $locale = null)
31
        {
32
            return '[trans]'.$id.'[/trans]';
33
        }
34
35
        public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
36
        {
37
            return '[trans]'.$id.'[/trans]';
38
        }
39
40
        public function setLocale($locale)
41
        {
42
        }
43
44
        public function getLocale()
45
        {
46
        }
47
    }
48
}
49