Priorities   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 8
eloc 15
c 1
b 0
f 1
dl 0
loc 30
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultPriority() 0 8 3
A all() 0 6 2
A findByName() 0 9 3
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: aappen
5
 * Date: 02.10.18
6
 * Time: 14:28
7
 */
8
9
namespace seretos\testrail\api;
10
11
12
class Priorities extends AbstractApi
13
{
14
    private $cache = null;
15
    public function all()
16
    {
17
        if ($this->cache === null) {
18
            $this->cache = $this->connector->send_get('get_priorities');
19
        }
20
        return $this->cache;
21
    }
22
23
    public function findByName(string $name)
24
    {
25
        $priorities = $this->all();
26
        foreach ($priorities as $priority) {
27
            if ($priority['name'] === $name) {
28
                return $priority;
29
            }
30
        }
31
        return [];
32
    }
33
34
    public function getDefaultPriority() {
35
        $priorities = $this->all();
36
        foreach ($priorities as $priority) {
37
            if ($priority['is_default'] === true) {
38
                return $priority;
39
            }
40
        }
41
        return [];
42
    }
43
}