Completed
Push — develop ( 6b358f...19e70a )
by Patrick
08:59 queued 05:47
created

SQLUser::isInGroupNamed()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
nc 3
nop 1
dl 0
loc 17
rs 9.2
c 0
b 0
f 0
1
<?php
2
namespace Auth;
3
4
class SQLUser extends User
5
{
6
    private $data;
7
    private $auth;
8
9
    /**
10
     * Initialize a SQLUser object
11
     *
12
     * @param boolean|array $data The data to initialize the SQLUser with or false for an empty User
13
     * @param boolean|\Auth\SQLAuthenticator The SQLAuthenticator instance that produced this user
14
     */
15
    public function __construct($data = false, $auth = false)
16
    {
17
        $this->data = array();
18
        $this->auth = $auth;
19 View Code Duplication
        if($data !== false)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
        {
21
            $this->data = $data;
22
            if(isset($data['extended']))
23
            {
24
                $this->data = $data['extended'];
25
            }
26
        }
27
    }
28
29
    public function isInGroupNamed($name)
30
    {
31
        if($this->auth === false)
32
        {
33
            return false;
34
        }
35
        $auth_data_set = $this->auth->dataSet;
36
        $group_data_table = $auth_data_set['group'];
37
        $uid = $this->uid;
38
        $filter = new \Data\Filter("uid eq '$uid' and gid eq '$name'");
39
        $groups = $group_data_table->read($filter);
40
        if($groups === false || !isset($groups[0]))
41
        {
42
            return false;
43
        }
44
        return true;
45
    }
46
47
    public function __get($propName)
48
    {
49
        if(isset($this->data[$propName]))
50
        {
51
            return $this->data[$propName];
52
        }
53
        return false;
54
    }
55
56
    public function __set($propName, $value)
57
    {
58
    }
59
}
60
/* vim: set tabstop=4 shiftwidth=4 expandtab: */
61