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

Behavior::UpdateEvent()   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 0
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 Behavior 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() . "/behavior");
16 11
    }
17
18
    /**
19
     * Get a list of behaviors
20
     * @param object Containing query arguments
21
     * @return object Result of the request
22
     */
23
    public function Get($args = array("limit" => 50))
24
    {
25
        return $this->request(Client::HTTP_GET, $this->GetUrl(), $args);
26
    }
27
28
    /**
29
     * Get a list of Visits
30
     * @param object Containing query arguments
31
     * @return object Result of the request
32
     */
33
    public function GetVisit($args = array("limit" => 50))
34
    {
35
        return $this->request(Client::HTTP_GET, $this->GetUrl()."/visit", $args);
36
    }
37
38
    /**
39
     * Get one or multiple events
40
     * @param string event id, leave null for list of events
41
     * @param object Containing query arguments
42
     * @return object Result of the request
43
     */
44
    public function GetEvent($eventId = null, $args = array("limit" => 50))
45
    {
46
        if (is_null($eventId)) {
47
            return $this->request(Client::HTTP_GET, $this->GetUrl()."/event", $args);
48
        }
49
        return $this->request(Client::HTTP_GET, $this->GetUrl()."/event/".$eventId, $args);
50
    }
51
52
    /**
53
     * Create new event
54
     * @param object Containing all the information of a event
55
     * @return object Result of the request
56
     */
57
    public function CreateEvent($event)
58
    {
59
        return $this->request(Client::HTTP_POST, $this->GetUrl()."/event", $event);
60
    }
61
62
    /**
63
     * Update a event
64
     * @param object Event containing the eventid and fields that need to be updated
65
     * @throws \Exception When eventid is not present
66
     * @return object Result of the request
67
     */
68
    public function UpdateEvent($event)
69
    {
70
        if (!isset($event['eventid'])) {
71
            throw new \Exception("event must contain a eventid");
72
        }
73
74
        return $this->request(Client::HTTP_PUT, $this->GetUrl()."/event/".$event['eventid'], $event);
75
    }
76
77
    /**
78
     * Updates a maximum of 50 events at a time.
79
     * @param array Containing events with a maximum of 50
80
     * @throws \Exception When more that 50 events are provided
81
     * @return object Result of the request
82
     */
83
    public function Bulk($events)
84
    {
85
        if (count($events) > 50) {
86
            throw new \Exception("Maximum of 50 events allowed at a time");
87
        }
88
        return $this->request(Client::HTTP_POST, $this->GetUrl()."/event/bulk", ['items' => $events]);
89
    }
90
}
91