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

LDAPObject   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 9
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
B jsonSerialize() 0 29 8
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