Completed
Push — master ( cc864c...f8b489 )
by Akram
02:32
created

Job::get()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 12
loc 12
ccs 0
cts 12
cp 0
rs 9.4285
cc 3
eloc 8
nc 3
nop 2
crap 12
1
<?php
2
3
namespace Rundeck\Resources;
4
5
use Rundeck\HttpClient;
6
7
class Job
8
{
9
10
    private $name;
11
    private $client;
12
13
    private $actions = [
14
        "executions" => ["xml"],
15
        "input/files" => ["xml"],
16
        "info" => ["xml"],
17
    ];
18
19
    public function __construct(HttpClient $client, $name = null)
20
    {
21
        $this->name = $name;
22
        $this->client = $client;
23
    }
24
25
    public function find($alt = "xml")
26
    {
27
        $response = $this->client->get('/job/'.$this->name, $alt);
28
        return $response;
29
    }
30
31 View Code Duplication
    public function get($action, $alt = "xml")
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        if (array_key_exists($action, $this->actions)) {
34
            if (!in_array($alt, $this->actions[$action])) {
35
                throw new \Exception("Invalid Format: ". $alt);
36
            }
37
            $response = $this->client->get('/job/'.$this->name. '/' .$action, $alt);
38
            return $response;
39
        } else {
40
            throw new \Exception("Action invalid.");
41
        }
42
    }
43
}
44