LegacyLdapChoiceLoader   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 28
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A load() 0 4 1
1
<?php
2
/**
3
 * This file is part of the LdapToolsBundle package.
4
 *
5
 * (c) Chad Sikorra <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LdapTools\Bundle\LdapToolsBundle\Form\ChoiceLoader;
12
13
use LdapTools\LdapManager;
14
use LdapTools\Object\LdapObject;
15
16
/**
17
 * Gets an array of LDAP objects to be passed to the ObjectChoiceList for pre-Symfony 2.7 compatibility.
18
 *
19
 * @author Chad Sikorra <[email protected]>
20
 */
21
class LegacyLdapChoiceLoader
22
{
23
    use LdapObjectChoiceTrait;
24
25
    /**
26
     * @param LdapManager $ldap
27
     * @param string $type The LDAP object type.
28
     * @param string $labelAttribute The LDAP attribute to use for the label.
29
     * @param string $id The attribute to use for the ID.
30
     * @param LdapQueryBuilder|\Closure|null
31
     */
32
    public function __construct(LdapManager $ldap, $type, $labelAttribute = 'name', $id = 'guid', $query = null)
33
    {
34
        $this->ldap = $ldap;
35
        $this->type = $type;
36
        $this->id = $id;
37
        $this->labelAttribute = $labelAttribute;
38
        $this->setClosureOrQuery($query);
39
    }
40
41
    /**
42
     * @return LdapObject[]
43
     */
44
    public function load()
45
    {
46
        return $this->getLdapObjectsByQuery()->toArray();
47
    }
48
}
49