Completed
Push — FVSv2 ( 9a40f1...ab906d )
by Patrick
01:31
created

VolunteerDepartment::getPrivateDepartments()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 17
loc 17
rs 9.7
c 0
b 0
f 0
1
<?php
2
class VolunteerDepartment
3
{
4
    protected $dbData;
5
6 View Code Duplication
    public function __construct($departmentID, $dbData = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
7
    {
8
        if($dbData === null)
9
        {
10
            $dataTable = DataSetFactory::getDataTableByNames('fvs', 'departments');
11
            $filter = new \Data\Filter('departmentID eq '.$departmentID);
12
            $depts = $dataTable->read($filter);
13
            if(empty($depts))
14
            {
15
                throw new Exception('Unable to locate department with ID '.$departmentID);
16
            }
17
            $dbData = $depts[0];
18
        }
19
        $this->dbData = $dbData;
20
    }
21
22 View Code Duplication
    public function getLeadEmails()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in 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...
23
    {
24
        $leadTitle = $dbData['lead'];
0 ignored issues
show
Bug introduced by
The variable $dbData does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
25
        $auth = \AuthProvider::getInstance();
26
        $users = $auth->getUsersByFilter(new \Data\Filter('title eq '.$leadTitle), array('mail'));
27
        if(empty($users))
28
        {
29
            return null;
30
        }
31
        $count = count($users);
32
        for($i = 0; $i < $count; $i++)
33
        {
34
            $users[$i] = $users[$i]['mail'];
35
        }
36
        return $users;
37
    }
38
39 View Code Duplication
    public static function getPrivateDepartments()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in 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...
40
    {
41
        $dataTable = DataSetFactory::getDataTableByNames('fvs', 'departments');
42
        $filter = new \Data\Filter('public eq false');
43
        $depts = $dataTable->read($filter);
44
        $res = array();
45
        if(empty($depts))
46
        {
47
            return $res;
48
        }
49
        $count = count($depts);
50
        for($i = 0; $i < $count; $i++)
51
        {
52
            array_push($res, $depts[$i]['departmentID']);
53
        }
54
        return $res;
55
    }
56
}
57