Completed
Push — master ( a50fa9...52e74d )
by Christopher
05:49
created

SchemaTrait::getAttributes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 9
rs 9.6666
c 1
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
/**
3
 * @link      https://github.com/chrmorandi/yii2-ldap for the canonical source repository
4
 * @package   yii2-ldap
5
 * @author    Christopher Mota <[email protected]>
6
 * @license   MIT License - view the LICENSE file that was distributed with this source code.
7
 */
8
9
namespace chrmorandi\ldap\schemas;
10
11
use ReflectionClass;
12
use ReflectionProperty;
13
14
/**
15
 *
16
 * @since 1.0.0
17
 */
18
trait SchemaTrait {
19
    
20
    /**
21
     * The LDAP API references an LDAP object by its distinguished name (DN).
22
     * A DN is a sequence of relative distinguished names (RDN) connected by commas.
23
     *
24
     * @link https://msdn.microsoft.com/en-us/library/aa366101(v=vs.85).aspx
25
     * @var  string
26
     */
27
    public $dn;
28
    
29
     /**
30
     * Returns the list of attribute names.
31
     * By default, this method returns all public properties of the class.
32
     * @return array list of attribute names.
33
     */
34
    public function getAttributes() {
35
        $class = new ReflectionClass(self::class);
36
        $names = [];
37
        foreach ($class->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
38
            $names[] = $property->getName();
39
        }
40
        
41
        return $names;
42
    }
43
}
44