Users   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
eloc 10
c 1
b 0
f 1
dl 0
loc 19
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A find() 0 8 4
A all() 0 5 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: aappen
5
 * Date: 17.10.18
6
 * Time: 15:54
7
 */
8
9
namespace seretos\testrail\api;
10
11
12
class Users extends AbstractApi
13
{
14
    private $cache = null;
15
16
    public function all() {
17
        if ($this->cache === null) {
18
            $this->cache = $this->connector->send_get('get_users');
19
        }
20
        return $this->cache;
21
    }
22
23
    public function find(string $name) {
24
        $users = $this->all();
25
        foreach ($users as $user) {
26
            if ($user['name'] === $name || $user['email'] === $name) {
27
                return $user;
28
            }
29
        }
30
        return [];
31
    }
32
}