Passed
Branch master (608a5d)
by Simon
01:54
created

AnnotateClassInfo::getDocComment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverLeague\IDEAnnotator;
4
5
use ReflectionClass;
6
use ReflectionException;
7
use SilverStripe\Core\Manifest\ModuleLoader;
8
9
/**
10
 * Class AnnotateClassInfo
11
 * We will need this for phpDocumentor as well.
12
 */
13
class AnnotateClassInfo
14
{
15
    /**
16
     * @var string
17
     */
18
    protected $className = '';
19
20
    /**
21
     * @var ReflectionClass
22
     */
23
    protected $reflector;
24
25
    /**
26
     * AnnotateClassInfo constructor.
27
     *
28
     * @param $className
29
     * @throws ReflectionException
30
     */
31
    public function __construct($className)
32
    {
33
        $this->className = $className;
34
35
        $this->reflector = new ReflectionClass($className);
36
    }
37
38
    /**
39
     * Where module name is a folder in the webroot.
40
     *
41
     * @return string
42
     */
43
    public function getModuleName()
44
    {
45
        $relativePath = str_replace(BASE_PATH . DIRECTORY_SEPARATOR, '', $this->reflector->getFileName());
46
        list($moduleName) = explode(DIRECTORY_SEPARATOR, $relativePath);
47
48
        return (string)$moduleName;
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getClassFilePath()
55
    {
56
        return $this->reflector->getFileName();
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    public function getDocComment()
63
    {
64
        return $this->reflector->getDocComment();
65
    }
66
}
67