ServiceIdGenerator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateForBundleClass() 0 16 2
1
<?php
2
3
namespace Knp\RadBundle\DependencyInjection;
4
5
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
6
use Symfony\Component\DependencyInjection\Container;
7
8
class ServiceIdGenerator
9
{
10
    public function generateForBundleClass(BundleInterface $bundle, $className, $withSuffix = false)
11
    {
12
        $namespace = $bundle->getNamespace();
13
        $extension = $bundle->getContainerExtension();
14
15
        $extensionAlias = $extension->getAlias();
16
17
        $bundleClass = substr($className, strlen($namespace) + 1);
18
        $bundlePart = str_replace('\\', '.', Container::underscore($bundleClass));
19
20
        if (false !== $withSuffix) {
21
            $bundlePart .= '_'.$withSuffix;
22
        }
23
24
        return sprintf('%s.%s', $extensionAlias, $bundlePart);
25
    }
26
}
27