Completed
Push — master ( f0fd1d...defc9d )
by Christopher
40:01 queued 02:21
created

Schema::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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;
10
11
use chrmorandi\ldap\schemas\ActiveDirectory;
12
use yii\base\Object;
13
14
class Schema extends Object
15
{
16
    /**
17
     * The current LDAP attribute schema.
18
     *
19
     * @var SchemaInterface
20
     */
21
    protected $current;
22
23
    /**
24
     * Returns the current LDAP attribute schema.
25
     *
26
     * @return SchemaInterface
27
     */
28
    public function get()
29
    {
30
        if (!$this->current instanceof SchemaInterface) {
31
            $this->set(static::getDefault());
32
        }
33
34
        return $this->current;
35
    }
36
37
    /**
38
     * Sets the current LDAP attribute schema.
39
     *
40
     * @param SchemaInterface $schema
41
     */
42
    public function set(SchemaInterface $schema)
43
    {
44
        $this->current = $schema;
45
    }
46
47
    /**
48
     * Returns a new instance of the default schema.
49
     *
50
     * @return SchemaInterface
51
     */
52
    public static function getDefault()
53
    {
54
        return new ActiveDirectory();
55
    }
56
}
57