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 ( fb4bbc...dcdbd9 )
by Nico
29:09 queued 02:20
created

Behavior   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 1
dl 0
loc 83
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A Get() 0 4 1
A GetVisit() 0 4 1
A GetEvent() 0 4 2
A CreateEvent() 0 4 1
A UpdateEvent() 0 8 2
A UpdateBulk() 0 8 2
1
<?php
2
namespace Datatrics\API\Modules;
3
4
class Behavior extends Base
5
{
6
    /**
7
     * Private constructor so only the client can create this
8
     * @param string $apikey
9
     * @param string $projectid
10
     */
11
    public function __construct($apikey, $projectid)
12
    {
13
        parent::__construct($apikey, "/project/" . $projectid . "/behavior");
14
    }
15
16
    /**
17
     * Get a list of behaviors
18
     * @param object Containing query arguments
19
     * @return object Result of the request
20
     */
21
    public function Get($args = array("limit" => 50))
22
    {
23
        return $this->request(self::HTTP_GET, "?".http_build_query($args));
24
    }
25
26
    /**
27
     * Get a list of Visits
28
     * @param object Containing query arguments
29
     * @return object Result of the request
30
     */
31
    public function GetVisit($args = array("limit" => 50))
32
    {
33
        return $this->request(self::HTTP_GET, "/visit?".http_build_query($args));
34
    }
35
36
    /**
37
     * Get one or multiple events
38
     * @param string event id, leave null for list of events
39
     * @param object Containing query arguments
40
     * @return object Result of the request
41
     */
42
    public function GetEvent($eventId = null, $args = array("limit" => 50))
43
    {
44
        return $eventId == null ? $this->request(self::HTTP_GET, "/event?".http_build_query($args)) : $this->request(self::HTTP_GET, "/event/".$eventId."?".http_build_query($args));
45
    }
46
47
    /**
48
     * Create new event
49
     * @param object Containing all the information of a event
50
     * @return object Result of the request
51
     */
52
    public function CreateEvent($event)
53
    {
54
        return $this->request(self::HTTP_POST, "/evet", $event);
55
    }
56
57
    /**
58
     * Update a event
59
     * @param object Event containing the eventid and fields that need to be updated
60
     * @throws \Exception When eventid is not present
61
     * @return object Result of the request
62
     */
63
    public function UpdateEvent($event)
64
    {
65
        if (!isset($event['eventid'])) {
66
            throw new \Exception("event must contain a eventid");
67
        }
68
69
        return $this->request(self::HTTP_PUT, "/event/".$event['eventid'], $profile);
0 ignored issues
show
Bug introduced by
The variable $profile does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
70
    }
71
72
    /**
73
     * Updates a maximum of 50 events at a time.
74
     * @param array Containing events with a maximum of 50
75
     * @throws \Exception When more that 50 events are provided
76
     * @return object Result of the request
77
     */
78
    public function UpdateBulk($events)
79
    {
80
        if (count($events) > 50) {
81
            throw new \Exception("Maximum of 50 events allowed at a time");
82
        }
83
84
        return $this->request(self::HTTP_POST, "/event/bulk", $events);
85
    }
86
}
87