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

Boards   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 27.45 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
c 2
b 1
f 0
lcom 1
cbo 5
dl 14
loc 51
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 SearchProvider
11
{
12
    /**
13
     * Get all logged-in user boards
14
     *
15
     * @return array|bool
16
     */
17
    public function my()
18
    {
19
        $this->request->checkLoggedIn();
20
21
        $get = BoardHelper::createBoardsInfoRequest();
22
        $getString = UrlHelper::buildRequestString($get);
23
        $response = $this->request->exec(UrlHelper::RESOURCE_GET_BOARDS."?{$getString}");
24
25
        return $this->response->getData($response, 'all_boards');
26
    }
27
28
    /**
29
     * Follow board by boardID
30
     *
31
     * @param int $boardId
32
     * @return bool
33
     */
34 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...
35
    {
36
        $this->request->checkLoggedIn();
37
38
        $response = $this->request->followMethodCall($boardId, Request::BOARD_ENTITY_ID, UrlHelper::RESOURCE_FOLLOW_BOARD);
39
        return $this->response->checkResponse($response);
40
    }
41
42
    /**
43
     * Unfollow board by boardID
44
     *
45
     * @param int $boardId
46
     * @return bool
47
     */
48 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...
49
    {
50
        $this->request->checkLoggedIn();
51
52
        $response = $this->request->followMethodCall($boardId, Request::BOARD_ENTITY_ID, UrlHelper::RESOURCE_UNFOLLOW_BOARD);
53
        return $this->response->checkResponse($response);
54
    }
55
56
    protected function getScope()
57
    {
58
        return 'boards';
59
    }
60
}