VolunteerDepartment   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 21
c 3
b 0
f 0
dl 0
loc 40
rs 10
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getLeadEmails() 0 15 3
A getPrivateDepartments() 0 16 3
A __construct() 0 3 1
1
<?php
2
class VolunteerDepartment extends VolunteerObject
3
{
4
    public function __construct($departmentID, $dbData = null)
5
    {
6
        parent::__construct($departmentID, $dbData, 'departments', 'departmentID');
7
    }
8
9
    public function getLeadEmails()
10
    {
11
        $leadTitle = $this->dbData['lead'];
12
        $auth = \AuthProvider::getInstance();
13
        $users = $auth->getUsersByFilter(new \Data\Filter('title eq '.$leadTitle), array('mail'));
14
        if(empty($users))
15
        {
16
            return null;
17
        }
18
        $count = count($users);
19
        for($i = 0; $i < $count; $i++)
20
        {
21
            $users[$i] = $users[$i]['mail'];
22
        }
23
        return $users;
24
    }
25
26
    public static function getPrivateDepartments()
27
    {
28
        $dataTable = DataSetFactory::getDataTableByNames('fvs', 'departments');
29
        $filter = new \Data\Filter('public eq false');
30
        $depts = $dataTable->read($filter);
31
        $res = array();
32
        if(empty($depts))
33
        {
34
            return $res;
35
        }
36
        $count = count($depts);
0 ignored issues
show
Bug introduced by
It seems like $depts can also be of type boolean; however, parameter $var of count() does only seem to accept Countable|array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
        $count = count(/** @scrutinizer ignore-type */ $depts);
Loading history...
37
        for($i = 0; $i < $count; $i++)
38
        {
39
            array_push($res, $depts[$i]['departmentID']);
40
        }
41
        return $res;
42
    }
43
}
44