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

Content   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A Get() 0 9 4
A Create() 0 4 1
A Update() 0 4 1
A Delete() 0 9 3
A UpdateBulk() 0 8 2
1
<?php
2
namespace Datatrics\API\Modules;
3
4
class Content 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 . "/content");
14
    }
15
16
    /**
17
     * Get one or multiple contents
18
     * @param string content id, leave null for list of boxes
19
     * @param object Containing query arguments
20
     * @return object Result of the request
21
     */
22
    public function Get($contentId = null, $args = array("limit" => 50, 'type' => 'item', 'itemtype' => 'product'))
23
    {
24
        if ($contentId) {
25
            if (!isset($args['source'])) {
26
                throw new \Exception('Source is required');
27
            }
28
        }
29
        return $contentId == null ? $this->request(self::HTTP_GET, "?".http_build_query($args)) : $this->request(self::HTTP_GET, "/".$contentId."?".http_build_query($args));
30
    }
31
32
    /**
33
     * Create new content
34
     * @param object Containing all the information of a content
35
     * @return object Result of the request
36
     */
37
    public function Create($content)
38
    {
39
        return $this->request(self::HTTP_POST, "", $content);
40
    }
41
42
    /**
43
     * Create new content
44
     * @param id of the content
45
     * @param object Containing all the information of a content
46
     * @return object Result of the request
47
     */
48
    public function Update($contentId, $content)
49
    {
50
        return $this->request(self::HTTP_PUT, "/".$contentId, $content);
51
    }
52
53
    /**
54
     * Delete a content object by content id
55
     * @param string Id of the content
56
     * @return object Result of the request
57
     */
58
    public function Delete($contentId, $args = array('type' => 'item', 'itemtype' => 'product'))
59
    {
60
        if ($contentId) {
61
            if (!isset($args['source'])) {
62
                throw new \Exception('Source is required');
63
            }
64
        }
65
        return $this->request(self::HTTP_DELETE, "/".$contentId."?".http_build_query($args));
66
    }
67
68
    /**
69
     * Updates a maximum of 50 content items at a time.
70
     * @param array Containing content items with a maximum of 50
71
     * @throws \Exception When more that 50 content items are provided
72
     * @return object Result of the request
73
     */
74
    public function UpdateBulk($items)
75
    {
76
        if (count($items) > 50) {
77
            throw new \Exception("Maximum of 50 content items allowed at a time");
78
        }
79
80
        return $this->request(self::HTTP_POST, "/bulk", ['items' => $items]);
81
    }
82
}
83