BundleNameFromClassName   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 0
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getBundleName() 0 10 3
1
<?php
2
namespace kujaff\VersionsBundle\Model;
3
4
/**
5
 * Define a protected property ContainerInterface $container and define it in __construct(ContainerInterface $container)
6
 */
7
trait BundleNameFromClassName
8
{
9
10
	/**
11
	 * Return bundle name, search for it in class namespace
12
	 *
13
	 * @return string
14
     * @throws \Exception
15
	 */
16
	public function getBundleName()
17
	{
18
		$parts = array_reverse(explode('\\', get_called_class()));
19
		foreach ($parts as $part) {
20
			if (substr($part, -6) == 'Bundle') {
21
				return $part;
22
			}
23
		}
24
		throw \Exception('Bundle name cannot be found in "' . get_called_class() . '" class name.');
25
	}
26
27
}
28