Completed
Push — master ( a63df8...25710f )
by Akram
02:20
created

Rundeck   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 92.86%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 0
cbo 1
dl 0
loc 42
ccs 13
cts 14
cp 0.9286
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setClient() 0 4 1
A __call() 0 11 2
1
<?php
2
3
namespace Rundeck;
4
5
class Rundeck
6
{
7
    /**
8
     * @var HttpClient
9
     */
10
    private $client;
11
12
    /**
13
     * Create a new Rundeck Instance
14
     */
15 3
    public function __construct($endpoint, $authToken, $version)
16
    {
17 3
        $this->client = new HttpClient();
18 3
        $this->client->setAuth($endpoint, $authToken, $version);
19 3
    }
20
21
    /**
22
     * @param HttpClient $client
23
     */
24 3
    public function setClient($client)
25
    {
26 3
        $this->client = $client;
27 3
    }
28
29
    /**
30
     * @param $name
31
     * @param $arguments
32
     * @return object
33
     * @throws \Exception
34
     */
35 3
    public function __call($name, $arguments)
36
    {
37 3
        $className = "\\Rundeck\\Resources\\".ucfirst($name);
38 3
        if (class_exists($className)) {
39 3
            array_unshift($arguments, $this->client);
40 3
            $resource = new \ReflectionClass($className);
41 3
            return $resource->newInstanceArgs($arguments);
42
        } else {
43
            throw new \Exception("This resource doesn't exist.");
44
        }
45
    }
46
}
47