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

Profile::Bulk()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
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 8
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 Profile 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/" . $this->GetClient()->GetProjectId() . "/profile");
16 20
    }
17
18
    /**
19
     * Get one or multiple profiles
20
     * @param string profile id, leave null for list of profiles
21
     * @param object Containing query arguments
22
     * @return object Result of the request
23
     */
24
    public function Get($profileId = null, $args = array("limit" => 50))
25
    {
26
        if (is_null($profileId)) {
27
            return $this->GetClient()->Get($this->GetUrl(), $args);
28
        }
29
        return $this->GetClient()->Get($this->GetUrl()."/".$profileId, $args);
30
    }
31
32
    /**
33
     * Create new profile
34
     * @param object Containing all the information of a profile
35
     * @return object Result of the request
36
     */
37
    public function Create($profile)
38
    {
39
        return $this->GetClient()->Post($this->GetUrl(), $profile);
40
    }
41
42
    /**
43
     * Delete a profile by profileid
44
     * @param string Id of the profile to be deleted
45
     * @return object Result of the request
46
     */
47
    public function Delete($profileId)
48
    {
49
        return $this->GetClient()->Delete($this->GetUrl()."/".$profileId);
50
    }
51
52
    /**
53
     * Update a profile
54
     * @param object Profile containing the profileid and fields that need to be updated
55
     * @throws \Exception When profileid is not present
56
     * @return object Result of the request
57
     */
58
    public function Update($profile)
59
    {
60
        if (!isset($profile['profileid'])) {
61
            throw new \Exception("profile must contain a profileid");
62
        }
63
        return $this->GetClient()->Post($this->GetUrl()."/".$profile['profileid'], $profile);
64
    }
65
66
    /**
67
     * Updates a maximum of 50 profiles at a time.
68
     * @param array Containing profiles with a maximum of 50
69
     * @throws \Exception When more that 50 profiles are provided
70
     * @return object Result of the request
71
     */
72
    public function Bulk($profiles)
73
    {
74
        if (count($profiles) > 50) {
75
            throw new \Exception("Maximum of 50 profiles allowed at a time");
76
        }
77
78
        return $this->GetClient()->Post($this->GetUrl()."/bulk", ['items' => $profiles]);
79
    }
80
}
81