Completed
Push — develop ( ed6c74...ceecfe )
by Patrick
04:06
created

LDAPObject::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Flipside\LDAP;
3
4
class LDAPObject extends \Flipside\SerializableObject
5
{
6
    public $server;
7
8
    function __construct($array = false, $server = false)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
9
    {
10
        parent::__construct($array);
11
        $this->server = $server;
12
    }
13
14
    public function jsonSerialize()
15
    {
16
        $ret = array();
17
        foreach($this as $key => $value)
0 ignored issues
show
Bug introduced by
The expression $this of type this<Flipside\LDAP\LDAPObject> is not traversable.
Loading history...
18
        {
19
            if($key === 'server' || $key === 'count')
20
            {
21
                continue;
22
            }
23
            if(is_numeric($key))
24
            {
25
                continue;
26
            }
27
            if($key === 'jpegphoto')
28
            {
29
                $ret[$key] = base64_encode($value[0]);
30
                continue;
31
            }
32
            if(is_array($value) && $value['count'] === 1)
33
            {
34
                $ret[$key] = $value[0];
35
            }
36
            else
37
            {
38
                $ret[$key] = $value;
39
            }
40
        }
41
        return $ret;
42
    }
43
}
44
/* vim: set tabstop=4 shiftwidth=4 expandtab: */
45