Completed
Pull Request — master (#36)
by
unknown
05:15
created

Members   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 1
dl 39
loc 39
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 4 4 1
A filter() 7 7 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 Trello\Api\Organization;
4
5
use Trello\Api\AbstractApi;
6
use Trello\Api\Member;
7
use Trello\Exception\InvalidArgumentException;
8
9
/**
10
 * Trello Board Members API
11
 * @link https://trello.com/docs/api/board
12
 *
13
 * Fully implemented.
14
 */
15 View Code Duplication
class Members extends AbstractApi
0 ignored issues
show
Duplication introduced by
This class 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...
16
{
17
    /**
18
     * Base path of board members api
19
     * @var string
20
     */
21
    protected $path = 'organizations/#id#/members';
22
23
    /**
24
     * Get a given board's members
25
     * @link https://trello.com/docs/api/board/#get-1-boards-board-id-members
26
     *
27
     * @param string $id     the board's id
28
     * @param array  $params optional parameters
29
     *
30
     * @return array
31
     */
32 1
    public function all($id, array $params = array())
33
    {
34 1
        return $this->get($this->getPath($id), $params);
35
    }
36
37
    /**
38
     * Filter members related to a given board
39
     * @link https://trello.com/docs/api/board/#get-1-boards-board-id-members-filter
40
     *
41
     * @param string       $id     the board's id
42
     * @param string|array $filter array of / one of 'none', 'normal', 'admins', 'owners', 'all'
43
     *
44
     * @return array
45
     */
46 3
    public function filter($id, $filter = 'all')
47
    {
48 3
        $allowed = array('none', 'normal', 'admins', 'owners', 'all');
49 3
        $filters = $this->validateAllowedParameters($allowed, $filter, 'filter');
50
51 3
        return $this->get($this->getPath($id) . '/' . implode(',', $filters));
52
    }
53
}
54