Completed
Pull Request — master (#209)
by Sergey
03:41
created

Interests   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 20.45 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 9
loc 44
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A main() 0 4 1
A info() 0 4 1
A pins() 9 9 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 Generator;
6
use seregazhuk\PinterestBot\Api\Traits\HasFeed;
7
use seregazhuk\PinterestBot\Helpers\UrlBuilder;
8
use seregazhuk\PinterestBot\Api\Traits\HasRelatedTopics;
9
10
class Interests extends Provider
11
{
12
    use HasRelatedTopics, HasFeed;
13
14
    protected $feedUrl = UrlBuilder::RESOURCE_GET_CATEGORY_FEED;
15
16
    /**
17
     * Get list of main categories
18
     * 
19
     * @return array|bool
20
     */
21
    public function main()
22
    {
23
        return $this->execGetRequest(["category_types" => "main"], UrlBuilder::RESOURCE_GET_CATEGORIES);
24
    }
25
26
    /**
27
     * Get category info
28
     *
29
     * @param string $category
30
     * @return array|bool
31
     */
32
    public function info($category)
33
    {
34
        return $this->execGetRequest(["category" => $category], UrlBuilder::RESOURCE_GET_CATEGORY);
35
    }
36
37
    /**
38
     * Returns a feed of pins.
39
     *
40
     * @param string $interest
41
     * @param int $limit
42
     * @return Generator
43
     */
44 View Code Duplication
    public function pins($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...
45
    {
46
       $data = [
47
           'feed'             => $interest,
48
           'is_category_feed' => true,
49
       ];
50
51
        return $this->getFeed($data, UrlBuilder::RESOURCE_GET_CATEGORY_FEED, $limit);
52
    }
53
}
54