Custom   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 7
Bugs 0 Features 0
Metric Value
eloc 10
c 7
b 0
f 0
dl 0
loc 54
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getCustomBitlink() 0 3 1
A updateCustomBitlink() 0 3 1
A addCustomBitlink() 0 3 1
A getClicksForCustomBitlink() 0 3 1
A getCustomBitlinkMetricsByDestination() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
// Custom.php
4
#################################################
5
##
6
## PHPLicengine
7
##
8
#################################################
9
## Copyright 2009-{current_year} PHPLicengine
10
## 
11
## Licensed under the Apache License, Version 2.0 (the "License");
12
## you may not use this file except in compliance with the License.
13
## You may obtain a copy of the License at
14
##
15
##    http://www.apache.org/licenses/LICENSE-2.0
16
##
17
## Unless required by applicable law or agreed to in writing, software
18
## distributed under the License is distributed on an "AS IS" BASIS,
19
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
## See the License for the specific language governing permissions and
21
## limitations under the License.
22
#################################################
23
24
namespace PHPLicengine\Service;
25
use PHPLicengine\Exception\ResponseException;
26
use PHPLicengine\Exception\CurlException;
27
use PHPLicengine\Api\ApiInterface;
28
29
class Custom {
30
 
31
       private $url;
32
       private $api;      
33
      
34
       public function __construct(ApiInterface $api)
35
       {
36
              $this->api = $api;
37
              $this->url = 'https://api-ssl.bitly.com/v4/custom_bitlinks';       
38
       }
39
 
40
       /*
41
      Update Custom Bitlink
42
      https://dev.bitly.com/api-reference#updateCustomBitlink
43
      */
44
       public function updateCustomBitlink(string $custom_bitlink, array $params)
45
       {
46
              return $this->api->patch($this->url.'/'.$custom_bitlink, $params);
47
       }
48
49
       /*
50
      Retrieve Custom Bitlink
51
      https://dev.bitly.com/api-reference#getCustomBitlink
52
      */
53
       public function getCustomBitlink(string $custom_bitlink)
54
       {
55
              return $this->api->get($this->url.'/'.$custom_bitlink);
56
       }
57
      
58
       /*
59
      Add Custom Bitlink
60
      https://dev.bitly.com/api-reference#addCustomBitlink
61
      */
62
       public function addCustomBitlink(array $params)
63
       {
64
              return $this->api->post($this->url, $params);
65
       }
66
      
67
       /*
68
      Get Metrics for a Custom Bitlink by destination
69
      https://dev.bitly.com/api-reference#getCustomBitlinkMetricsByDestination
70
      */
71
       public function getCustomBitlinkMetricsByDestination(string $custom_bitlink, array $params = array())
72
       {
73
              return $this->api->get($this->url.'/'.$custom_bitlink.'/clicks_by_destination', $params);
74
       }
75
      
76
       /*
77
      Get Clicks for a Custom Bitlink's Entire History
78
      https://dev.bitly.com/api-reference#getClicksForCustomBitlink
79
      */
80
       public function getClicksForCustomBitlink(string $custom_bitlink, array $params = array())
81
       {
82
              return $this->api->get($this->url.'/'.$custom_bitlink."/clicks", $params);
83
       }
84
 
85
}
86