Completed
Push — master ( b86db6...b3547a )
by Sergey
39s
created

Topics   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 29.17 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 3
dl 14
loc 48
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getInfo() 0 4 1
A getPinsFor() 14 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace seregazhuk\PinterestBot\Api\Providers;
4
5
use seregazhuk\PinterestBot\Helpers\UrlBuilder;
6
use seregazhuk\PinterestBot\Api\Traits\Followable;
7
use seregazhuk\PinterestBot\Api\Traits\HasRelatedTopics;
8
9
class Topics extends Provider
10
{
11
    use Followable, HasRelatedTopics;
12
13
    /**
14
     * @var array
15
     */
16
    protected $loginRequiredFor = ['follow', 'unFollow'];
17
18
    protected $followUrl   = UrlBuilder::RESOURCE_FOLLOW_INTEREST;
19
    protected $unFollowUrl = UrlBuilder::RESOURCE_UNFOLLOW_INTEREST;
20
21
    protected $entityIdName = 'interest_id';
22
23
24
25
    /**
26
     * Get category info
27
     *
28
     * @param string $topic
29
     * @return array|bool
30
     */
31
    public function getInfo($topic)
32
    {
33
        return $this->execGetRequest(["interest" => $topic], UrlBuilder::RESOURCE_GET_TOPIC);
34
    }
35
36
    /**
37
     * Returns a feed of pins
38
     * @param string $interest
39
     * @param int $limit
40
     * @return array|bool
41
     */
42 View Code Duplication
    public function getPinsFor($interest, $limit = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        $params = [
45
            'data' => [
46
                'interest'  => $interest,
47
                'pins_only' => false,
48
            ],
49
            'url' => UrlBuilder::RESOURCE_GET_TOPIC_FEED
50
        ];
51
52
        return $this->getPaginatedResponse(
53
            $params, $limit
54
        );
55
    }
56
}