BundleTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 20
ccs 0
cts 15
cp 0
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A configureBundleDirs() 0 18 4
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Translation\Bundle\Command;
13
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\HttpKernel\Bundle\Bundle;
16
use Translation\Bundle\Model\Configuration;
17
18
trait BundleTrait
19
{
20
    private function configureBundleDirs(InputInterface $input, Configuration $config): void
21
    {
22
        if ($bundleName = $input->getOption('bundle')) {
23
            if (0 === \strpos($bundleName, '@')) {
24
                if (false === $pos = \strpos($bundleName, '/')) {
25
                    $bundleName = \substr($bundleName, 1);
26
                } else {
27
                    $bundleName = \substr($bundleName, 1, $pos - 2);
28
                }
29
            }
30
31
            /** @var Bundle $bundle */
32
            $bundle = $this->getApplication()
0 ignored issues
show
Bug introduced by
It seems like getApplication() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
            $bundle = $this->/** @scrutinizer ignore-call */ getApplication()
Loading history...
33
                ->getKernel()
34
                ->getBundle($bundleName)
35
            ;
36
37
            $config->reconfigureBundleDirs($bundle->getPath(), $bundle->getPath().'/Resources/translations');
38
        }
39
    }
40
}
41