GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — 2.0 ( 14ab12...ed0ed3 )
by Nico
05:48
created

Project::Update()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
namespace Datatrics\API\Modules;
3
4
use Datatrics\API\Client;
5
6
class Project extends Base
7
{
8
    /**
9
     * Private constructor so only the client can create this
10
     * @param Client $client
11
     */
12 20
    public function __construct(Client $client)
13
    {
14 20
        parent::__construct($client);
15 20
        $this->SetUrl("/project");
16 20
    }
17
18
    /**
19
     * Get one or multiple projects
20
     * @param string project id, leave null for list of boxes
21
     * @param object Containing query arguments
22
     * @return object Result of the request
23
     */
24
    public function Get($projectId = null, $args = array("limit" => 50))
25
    {
26
        if (is_null($projectId)) {
27
            return $this->GetClient()->Get($this->GetUrl(), $args);
28
        }
29
        return $this->GetClient()->Get($this->GetUrl()."/".$projectId, $args);
30
    }
31
32
    /**
33
     * Create new project
34
     * @param object Containing all the information of a project
35
     * @return object Result of the request
36
     */
37
    public function Create($project)
38
    {
39
        return $this->GetClient()->Post($this->GetUrl(), $project);
40
    }
41
42
    /**
43
     * Update a project
44
     * @param id of the project
45
     * @param object Containing all the information of a project
46
     * @throws \Exception when projectid is missing
47
     * @return object Result of the request
48
     */
49
    public function Update($project)
50
    {
51
        if (!isset($project['projectid'])) {
52
            throw new \Exception("project must contain a projectid");
53
        }
54
        return $this->GetClient()->Post($this->GetUrl()."/".$project['projectid'], $project);
55
    }
56
57
    /**
58
     * Delete a project object by project id
59
     * @param string Id of the project
60
     * @return object Result of the request
61
     */
62
    public function Delete($projectId)
63
    {
64
        return $this->GetClient()->Delete($this->GetUrl()."/".$projectId);
65
    }
66
67
    /**
68
     * Retrieve fields of a project object by project id
69
     * @param string Id of the project
70
     * @return object Result of the request
71
     */
72
    public function Fields($projectId)
73
    {
74
        return $this->GetClient()->Get($this->GetUrl()."/".$projectId."/fields");
75
    }
76
77
    /**
78
     * Retrieve logs of a project object by project id
79
     * @param string Id of the project
80
     * @return object Result of the request
81
     */
82
    public function Logs($projectId)
83
    {
84
        return $this->GetClient()->Get($this->GetUrl()."/".$projectId."/logs");
85
    }
86
}
87