Events   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 45
loc 45
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A listIssueEvents() 5 5 1
A listRepositoryEvents() 5 5 1
A getEvent() 5 5 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
namespace FlexyProject\GitHub\Receiver\Issues;
3
4
/**
5
 * The Trees API class provides access to Issues's events.
6
 *
7
 * @link    https://developer.github.com/v3/issues/events/
8
 * @package FlexyProject\GitHub\Receiver\Issues
9
 */
10 View Code Duplication
class Events extends AbstractIssues
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...
11
{
12
13
    /**
14
     * List events for an issue
15
     *
16
     * @link https://developer.github.com/v3/issues/events/#list-events-for-an-issue
17
     *
18
     * @param int $issueNumber
19
     *
20
     * @return array
21
     */
22
    public function listIssueEvents(int $issueNumber): array
23
    {
24
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/:issue_number/events',
25
            $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $issueNumber));
26
    }
27
28
    /**
29
     * List events for a repository
30
     *
31
     * @link https://developer.github.com/v3/issues/events/#list-events-for-a-repository
32
     * @return array
33
     */
34
    public function listRepositoryEvents(): array
35
    {
36
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/events',
37
            $this->getIssues()->getOwner(), $this->getIssues()->getRepo()));
38
    }
39
40
    /**
41
     * Get a single event
42
     *
43
     * @link https://developer.github.com/v3/issues/events/#get-a-single-event
44
     *
45
     * @param int $id
46
     *
47
     * @return array
48
     */
49
    public function getEvent(int $id): array
50
    {
51
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/events/:id',
52
            $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $id));
53
    }
54
}