Project::resource()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
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;
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