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

Project   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 60
ccs 13
cts 13
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A find() 0 5 1
A findAll() 0 5 1
A resource() 0 5 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;
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