Completed
Push — develop ( fae898...646b61 )
by Tom
04:48
created

ClassUtil::exists()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
/**
3
 * this file is part of magerun
4
 *
5
 * @author Tom Klingenberg <https://github.com/ktomk>
6
 */
7
namespace N98\Magento\Command\Developer\Module\Rewrite;
8
9
10
final class ClassUtil
11
{
12
    /**
13
     * @var string
14
     */
15
    private $className;
16
17
    /**
18
     * @var bool
19
     */
20
    private $exists;
21
22
    /**
23
     * @param string $className
24
     *
25
     * @return ClassUtil
26
     */
27
    public static function create($className)
28
    {
29
        return new self($className);
30
    }
31
32
    public function __construct($className)
33
    {
34
        $this->className = $className;
35
    }
36
37
    public function exists()
38
    {
39
        if (null === $this->exists) {
40
            $this->exists = ClassExistsChecker::create($this->className)->existsExtendsSafe();
41
        }
42
43
        return $this->exists;
44
    }
45
46
    /**
47
     * This class is a $class (is or inherits from it)
48
     *
49
     * @param ClassUtil $class
50
     * @return bool
51
     */
52
    public function isA(ClassUtil $class)
53
    {
54
        return is_a($this->className, $class->className, true);
55
    }
56
}
57