Templates::findByName()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 9
rs 10
cc 3
nc 3
nop 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: aappen
5
 * Date: 01.10.18
6
 * Time: 18:14
7
 */
8
9
namespace seretos\testrail\api;
10
11
12
class Templates extends AbstractApi
13
{
14
    private $cache = null;
15
    public function all(int $projectId)
16
    {
17
        if ($this->cache === null) {
18
            $this->cache = $this->connector->send_get('get_templates/'.$this->encodePath($projectId));
19
        }
20
        return $this->cache;
21
    }
22
23
    public function findByName(int $projectId, string $name)
24
    {
25
        $templates = $this->all($projectId);
26
        foreach ($templates as $template) {
27
            if ($template['name'] === $name) {
28
                return $template;
29
            }
30
        }
31
        return [];
32
    }
33
}