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 ( 5e7ce8...036b94 )
by Nico
06:29
created

Scorecard::Create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
namespace Datatrics\API\Modules;
3
4
use Datatrics\API\Client;
5
6
class Scorecard extends Base
7
{
8
    /**
9
     * Private constructor so only the client can create this
10
     * @param Client $client
11
     */
12 11
    public function __construct(Client $client)
13
    {
14 11
        parent::__construct($client);
15 11
        $this->SetUrl("/project/" . $this->GetClient()->GetProjectId() . "/scorecard");
16 11
    }
17
18
    /**
19
     * Get one or multiple scorecards
20
     * @param string scorecard 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($scorecardId = null, $args = array("limit" => 50))
25
    {
26
        if (is_null($scorecardId)) {
27
            return $this->GetClient()->Get($this->GetUrl(), $args);
28
        }
29
        return $this->GetClient()->Get($this->GetUrl()."/".$scorecardId, $args);
30
    }
31
32
    /**
33
     * Create new scorecard
34
     * @param object Containing all the information of a scorecard
35
     * @return object Result of the request
36
     */
37
    public function Create($scorecard)
38
    {
39
        return $this->GetClient()->Post($this->GetClient(), $scorecard);
0 ignored issues
show
Documentation introduced by
$this->GetClient() is of type object<Datatrics\API\Client>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
40
    }
41
42
    /**
43
     * Delete a scorecard object by scorecard id
44
     * @param string Id of the scorecard
45
     * @return object Result of the request
46
     */
47
    public function Delete($scorecardId)
48
    {
49
        return $this->GetClient()->Delete($this->GetClient()."/".$scorecardId);
50
    }
51
52
    /**
53
     * Updates a maximum of 50 scorecard items at a time.
54
     * @param array Containing scorecards with a maximum of 50
55
     * @throws \Exception When more that 50 content items are provided
56
     * @return object Result of the request
57
     */
58
    public function Bulk($scorecards)
59
    {
60
        if (count($scorecards) > 50) {
61
            throw new \Exception("Maximum of 50 scorecards allowed at a time");
62
        }
63
64
        return $this->GetClient()->Post($this->GetClient()."/bulk", ['items' => $scorecards]);
65
    }
66
}
67