Manager::getFullBundlePath()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 2
eloc 6
nc 2
nop 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Rafidion Michael
5
 * Date: 03/09/2015
6
 * Time: 12:02
7
 */
8
9
namespace Mykees\CommentBundle\Manager;
10
11
12
abstract class Manager {
13
14
15
	/**
16
	 * @param $ref
17
	 * @return string
18
	 */
19
	public function getBundleShortName ( $ref ){
20
		$explode = explode('\\', $this->getClassName($ref));
21
		return $explode[0].$explode[1];
22
	}
23
24
25
	/**
26
	 * @param $ref
27
	 * @return string
28
	 */
29
	public function getBundlePath ( $ref ){
30
		$explode = explode('\\', $this->getClassName($ref));
31
		return $explode[0].'\\'.$explode[1];
32
	}
33
34
35
	/**
36
	 * @param $ref
37
	 * @param bool $withouSlash
38
	 * @return string
39
	 */
40
	public function getFullBundlePath($ref,$withouSlash = false)
41
	{
42
		$explode = explode('\\', $this->getClassName($ref));
43
		if($withouSlash)
44
		{
45
			return $explode[0].$explode[1].':'.$explode[3];
46
		}else{
47
			return $explode[0].'\\'.$explode[1].'\\'.$explode[2].'\\'.$explode[3];
48
		}
49
	}
50
51
52
	/**
53
	 * @param $ref
54
	 * @return string
55
	 */
56
	public function getClassShortName( $ref ) {
57
		$reflection = new \ReflectionClass( $ref );
58
		if( $reflection->getParentClass() ) {
59
			$reflection = $reflection->getParentClass();
60
		}
61
		return $reflection->getShortName();
62
	}
63
64
65
	/**
66
	 * @param $ref
67
	 * @return string
68
	 */
69
	public function getClassName ( $ref ) {
70
		$reflection = new \ReflectionClass( $ref );
71
		return $reflection->getName();
72
	}
73
74
	/**
75
	 * Retrieve class repository name
76
	 * @param $comment_class
77
	 * @return string
78
	 */
79
	public function classRepository($comment_class)
80
	{
81
		$comment_class_name = $comment_class;
82
		$explode = explode('\\',$comment_class_name);
83
84
		return $explode[0] . $explode[1] . ":" . $explode[3];
85
	}
86
}
87