Passed
Pull Request — master (#298)
by Alexander
02:11
created

SetLocaleEventHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 10
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
namespace App\EventHandler;
4
5
use Yiisoft\Translator\TranslatorInterface;
6
use Yiisoft\Yii\Middleware\Event\SetLocaleEvent;
7
8
final class SetLocaleEventHandler
9
{
10
    public function __construct(
11
        private TranslatorInterface $translator
12
    )
13
    {}
14
15
    public function handle(SetLocaleEvent $event): void
16
    {
17
        $this->translator->setLocale($event->getLocale());
18
    }
19
}
20