LocaleCompilerPass::process()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
crap 1
1
<?php
2
3
namespace BrainExe\Core\DependencyInjection\CompilerPass;
4
5
use BrainExe\Core\Annotations\CompilerPass;
6
use BrainExe\Core\Util\Glob;
7
use Exception;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
11
/**
12
 * @CompilerPass
13
 */
14
class LocaleCompilerPass implements CompilerPassInterface
15
{
16
    /**
17
     * {@inheritdoc}
18
     *
19
     * @throws Exception
20
     */
21 2
    public function process(ContainerBuilder $container)
22
    {
23
        /** @var Glob $glob */
24 2
        $glob = $container->get(Glob::class);
25
26 2
        $locales = $glob->execGlob(ROOT . 'lang/*.po');
27 2
        $locales = array_map(function ($file) {
28 1
            return basename($file, '.po');
29 2
        }, $locales);
30
31 2
        $container->setParameter('locales', $locales);
32 2
    }
33
}
34