Client   A
last analyzed

Complexity

Total Complexity 32

Size/Duplication

Total Lines 114
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 32
eloc 52
c 1
b 0
f 0
dl 0
loc 114
rs 9.84

18 Methods

Rating   Name   Duplication   Size   Complexity  
A fields() 0 2 1
A suites() 0 2 1
A getUser() 0 2 1
A results() 0 2 1
A types() 0 2 1
A configurations() 0 2 1
A sections() 0 2 1
A projects() 0 2 1
A __construct() 0 3 1
C api() 0 32 15
A milestones() 0 2 1
A cases() 0 2 1
A priorities() 0 2 1
A plans() 0 2 1
A create() 0 5 1
A statuses() 0 2 1
A users() 0 2 1
A templates() 0 2 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: aappen
5
 * Date: 01.10.18
6
 * Time: 14:19
7
 */
8
9
namespace seretos\testrail;
10
11
12
use seretos\testrail\api\Cases;
13
use seretos\testrail\api\Configurations;
14
use seretos\testrail\api\Fields;
15
use seretos\testrail\api\Milestones;
16
use seretos\testrail\api\Plans;
17
use seretos\testrail\api\Priorities;
18
use seretos\testrail\api\Projects;
19
use seretos\testrail\api\Results;
20
use seretos\testrail\api\Sections;
21
use seretos\testrail\api\Statuses;
22
use seretos\testrail\api\Suites;
23
use seretos\testrail\api\Templates;
24
use seretos\testrail\api\Types;
25
use seretos\testrail\api\Users;
26
use seretos\testrail\connector\ApiConnectorInterface;
27
use seretos\testrail\connector\TestRailAPIClient;
28
29
class Client
30
{
31
    /**
32
     * @var ApiConnectorInterface
33
     */
34
    private $connector;
35
36
    public function __construct(ApiConnectorInterface $connector)
37
    {
38
        $this->connector = $connector;
39
    }
40
41
    public static function create(string $url, string $user, string $password) {
42
        $connector = new TestRailAPIClient($url);
43
        $connector->set_user($user);
44
        $connector->set_password($password);
45
        return new self($connector);
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getUser() {
52
        return $this->connector->get_user();
53
    }
54
55
    public function projects() {
56
        return new Projects($this->connector);
57
    }
58
59
    public function suites() {
60
        return new Suites($this->connector);
61
    }
62
63
    public function sections() {
64
        return new Sections($this->connector);
65
    }
66
67
    public function cases() {
68
        return new Cases($this->connector);
69
    }
70
71
    public function templates() {
72
        return new Templates($this->connector);
73
    }
74
75
    public function types() {
76
        return new Types($this->connector);
77
    }
78
79
    public function fields() {
80
        return new Fields($this->connector);
81
    }
82
83
    public function priorities() {
84
        return new Priorities($this->connector);
85
    }
86
87
    public function milestones() {
88
        return new Milestones($this->connector);
89
    }
90
91
    public function plans() {
92
        return new Plans($this->connector);
93
    }
94
95
    public function configurations() {
96
        return new Configurations($this->connector);
97
    }
98
99
    public function results() {
100
        return new Results($this->connector);
101
    }
102
103
    public function statuses() {
104
        return new Statuses($this->connector);
105
    }
106
107
    public function users() {
108
        return new Users($this->connector);
109
    }
110
111
    public function api($name) {
112
        switch ($name) {
113
            case 'projects':
114
                return $this->projects();
115
            case 'suites':
116
                return $this->suites();
117
            case 'sections':
118
                return $this->sections();
119
            case 'cases':
120
                return $this->cases();
121
            case 'templates':
122
                return $this->templates();
123
            case 'types':
124
                return $this->types();
125
            case 'fields':
126
                return $this->fields();
127
            case 'priorities':
128
                return $this->priorities();
129
            case 'milestones':
130
                return $this->milestones();
131
            case 'plans':
132
                return $this->plans();
133
            case 'configurations':
134
                return $this->configurations();
135
            case 'results':
136
                return $this->results();
137
            case 'statuses':
138
                return $this->statuses();
139
            case 'users':
140
                return $this->users();
141
        }
142
        return null;
143
    }
144
}