TranslationTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getContainer() 0 9 2
A getLocales() 0 4 1
A getSlugLocales() 0 4 1
1
<?php
2
3
namespace ItBlaster\TranslationBundle\Traits;
4
5
/**
6
 * Вспомогательные методы для работы
7
 * с языковыми версиями
8
 *
9
 * Class TranslationTrait
10
 * @package ItBlaster\TranslationBundle\Trait
11
 */
12
trait TranslationTrait {
13
14
    protected $container;
15
16
    /**
17
     * Да да, тот самый контейнер, про который вы подумали
18
     *
19
     * @return mixed
20
     */
21
    protected function getContainer()
22
    {
23
        if (!$this->container) {
24
            $kernel = new \AppKernel('prod', false);
25
            $kernel->boot();
26
            $this->container = $kernel->getContainer();
27
        }
28
        return $this->container;
29
    }
30
31
    /**
32
     * Список локалей из конфига "it_blaster_translation.locales"
33
     *
34
     * @return array
35
     */
36
    protected function getLocales()
37
    {
38
        return $this->getContainer()->getParameter("it_blaster_translation.locales");
39
    }
40
41
    /**
42
     * Список локалей из конфига "it_blaster_translation.locales"
43
     *
44
     * @return array
45
     */
46
    protected function getSlugLocales()
47
    {
48
        return $this->getContainer()->getParameter("it_blaster_translation.slug_locales");
49
    }
50
}