Completed
Push — master ( 126036...3fa63d )
by Maik
07:56
created

OrmClassUtil::isInternalClass()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4286
cc 2
eloc 6
nc 3
nop 1
1
<?php
2
namespace Nkey\Caribu\Orm;
3
4
trait OrmClassUtil
5
{
6
7
    /**
8
     * Retrieve the properties from class
9
     *
10
     * @param string $class
11
     *            The name of class to get properties of
12
     *            
13
     * @return \ReflectionProperty[] Array of Reflection properties
14
     */
15
    private static function getClassProperties($class)
16
    {
17
        $rf = new \ReflectionClass($class);
18
        
19
        return $rf->getProperties();
20
    }
21
22
    /**
23
     * Checks whether a type is an internal class defined by core or any extension
24
     *
25
     * @param string $type
26
     *            The type (class name) to check
27
     *            
28
     * @return boolean
29
     */
30
    private static function isInternalClass($type)
31
    {
32
        try {
33
            $rf = new \ReflectionClass($type);
34
            return $rf->isInternal();
35
        } catch (\ReflectionException $exception) {
36
            // we do nothing and assume that the class is not checkable
37
        }
38
        return false;
39
    }
40
41
    /**
42
     * Build a full qualified class name including namespace
43
     *
44
     * @param string $ns
45
     *            The namespace of class
46
     * @param string $class
47
     *            The name of class
48
     *            
49
     * @return string The full qualified class name
50
     */
51
    private static function fullQualifiedName($ns, $class)
52
    {
53
        if (! class_exists($class)) {
54
            $class = sprintf("\\%s\\%s", $ns, $class);
55
        }
56
        return $class;
57
    }
58
}