Completed
Push — master ( 25710f...56c545 )
by Akram
02:12
created

Project::get()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 3.2098

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 12
loc 12
ccs 5
cts 7
cp 0.7143
rs 9.4285
cc 3
eloc 8
nc 3
nop 2
crap 3.2098
1
<?php
2
3
namespace Rundeck\Resources;
4
5
use Rundeck\HttpClient;
6
7
/**
8
 * Class Project /api/V/project/
9
 * @package Rundeck\Resources
10
 */
11
class Project extends Resource
12
{
13
14
    /**
15
     * @var array
16
     */
17
    protected $actions = [
18
        "jobs" => ["xml"],
19
        "jobs/export" => ["xml"],
20
        "resources" => ["xml"],
21
        "executions" => ["xml"],
22
        "executions/running" => ["xml"],
23
        "export" => ["xml"],
24
        "history" => ["xml"],
25
    ];
26
27
    /**
28
     * @param HttpClient $client
29
     * @param string $name : Execution ID
30
     */
31 15
    public function __construct(HttpClient $client, $name = null)
32
    {
33 15
        $this->name = $name;
34 15
        $this->client = $client;
0 ignored issues
show
Documentation Bug introduced by
It seems like $client of type object<Rundeck\HttpClient> is incompatible with the declared type object<Rundeck\Resources\HttpClient> of property $client.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
35 15
    }
36
37
    /**
38
     * Get project info
39
     * @param string $alt xml|json
40
     * @return array
41
     */
42 6
    public function find($alt = "xml")
43
    {
44 6
        $response = $this->client->get('/project/'.$this->name, $alt);
45 6
        return $response;
46
    }
47
48
    /**
49
     * Find all projects
50
     * @param string $alt
51
     * @return array
52
     */
53 3
    public function findAll($alt = "xml")
54
    {
55 3
        $response = $this->client->get('/projects', $alt);
56 3
        return $response;
57
    }
58
59
    /**
60
     * Get project resource
61
     * @param $name
62
     * @param string $alt xml|json
63
     * @return array
64
     */
65 3
    public function resource($name, $alt = "xml")
66
    {
67 3
        $response = $this->client->get('/project/'.$this->name. '/resource/' .$name, $alt);
68 3
        return $response;
69
    }
70
}
71