Completed
Pull Request — master (#19)
by Sergey
03:17
created

Boards   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 26.42 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 6
dl 14
loc 53
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A my() 0 10 1
A follow() 7 7 1
A unFollow() 7 7 1
A getScope() 0 4 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\Api\Request;
6
use seregazhuk\PinterestBot\Helpers\UrlHelper;
7
use seregazhuk\PinterestBot\Helpers\SearchHelper;
8
use seregazhuk\PinterestBot\Helpers\Requests\BoardHelper;
9
10
class Boards extends Provider
11
{
12
    use SearchHelper;
13
14
    /**
15
     * Get all logged-in user boards
16
     *
17
     * @return array|bool
18
     */
19
    public function my()
20
    {
21
        $this->request->checkLoggedIn();
22
23
        $get = BoardHelper::createBoardsInfoRequest();
24
        $getString = UrlHelper::buildRequestString($get);
25
        $response = $this->request->exec(UrlHelper::RESOURCE_GET_BOARDS."?{$getString}");
26
27
        return $this->response->getData($response, 'all_boards');
28
    }
29
30
    /**
31
     * Follow board by boardID
32
     *
33
     * @param int $boardId
34
     * @return bool
35
     */
36 View Code Duplication
    public function follow($boardId)
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...
37
    {
38
        $this->request->checkLoggedIn();
39
40
        $response = $this->request->followMethodCall($boardId, Request::BOARD_ENTITY_ID, UrlHelper::RESOURCE_FOLLOW_BOARD);
41
        return $this->response->checkResponse($response);
42
    }
43
44
    /**
45
     * Unfollow board by boardID
46
     *
47
     * @param int $boardId
48
     * @return bool
49
     */
50 View Code Duplication
    public function unFollow($boardId)
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...
51
    {
52
        $this->request->checkLoggedIn();
53
54
        $response = $this->request->followMethodCall($boardId, Request::BOARD_ENTITY_ID, UrlHelper::RESOURCE_UNFOLLOW_BOARD);
55
        return $this->response->checkResponse($response);
56
    }
57
58
    protected function getScope()
59
    {
60
        return 'boards';
61
    }
62
}