Completed
Pull Request — master (#36)
by
unknown
08:41
created

Boards   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 20 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 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
7
/**
8
 * Trello Organization Boards API
9
 * @link https://trello.com/docs/api/organization
10
 *
11
 * Fully implemented.
12
 */
13
class Boards extends AbstractApi
14
{
15
    protected $path = 'organization/#id#/boards';
16
17
    /**
18
     * Get boads related to a given organization
19
     * @link https://trello.com/docs/api/organization/#get-1-organizations-idorg-or-name-boards
20
     *
21
     * @param string $id     the organization's id or username
22
     * @param array  $params optional parameters
23
     *
24
     * @return array
25
     */
26 1
    public function all($id, array $params = array())
27
    {
28 1
        return $this->get($this->getPath($id), $params);
29
    }
30
31
    /**
32
     * Filter boards related to a given organization
33
     * @link https://trello.com/docs/api/organization/#get-1-organizations-idorg-or-name-boards-filter
34
     *
35
     * @param string       $id     the board's id
36
     * @param string|array $filter array of / one of 'all', none', 'open', 'closed', 'all'
37
     *
38
     * @return array
39
     */
40 3 View Code Duplication
    public function filter($id, $filter = 'all')
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...
41
    {
42 3
        $allowed = array('all', 'members', 'organization', 'public', 'open', 'closed', 'pinned', 'unpinned', 'starred');
43 3
        $filters = $this->validateAllowedParameters($allowed, $filter, 'filter');
44
45 3
        return $this->get($this->getPath($id).'/'.implode(',', $filters));
46
    }
47
}
48