Add   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A single() 0 18 4
1
<?php
2
namespace ArianRashidi\PocketApi\Api;
3
4
/**
5
 * Class Add
6
 *
7
 * @package ArianRashidi\PocketApi\Api
8
 */
9
class Add extends Api
10
{
11
    /**
12
     * Add a single link to Pocket.
13
     *
14
     * @param string      $url
15
     * @param string|null $title
16
     * @param array|null  $tags
17
     * @param int|null    $tweetId
18
     *
19
     * @return mixed
20
     */
21
    public function single(string $url, string $title = null, array $tags = null, int $tweetId = null)
22
    {
23
        $data = $this->keys() + ['time' => time(), 'url' => utf8_encode($url)];
24
        if (!is_null($title)) {
25
            $data = $data + ['title' => utf8_encode($title)];
26
        }
27
        if (!is_null($tags)) {
28
            $data = $data + ['tags' => implode(',', $tags)];
29
        }
30
        if (!is_null($tweetId)) {
31
            $data = $data + ['tweet_id' => $tweetId];
32
        }
33
34
        $response = $this->request('/v3/add', $data);
35
        $responseData = json_decode($response->getBody());
36
37
        return $responseData;
38
    }
39
}
40