GithubPullRequestConverter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 93.33 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 0
cbo 4
dl 42
loc 45
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A convert() 4 4 1
A getDateIfExists() 6 8 2

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 DevBoardLib\GithubObjectApiFacade\Repo\PullRequest\Converter;
4
5
use DateTime;
6
use DevBoardLib\GithubCore\Repo\GithubRepo;
7
use DevBoardLib\GithubObjectApiFacade\Repo\Commit\Converter\GithubCommitConvertTrait;
8
use DevBoardLib\GithubObjectApiFacade\Repo\Milestone\Converter\GithubMilestoneConvertTrait;
9
use DevBoardLib\GithubObjectApiFacade\User\Converter\GithubUserConvertTrait;
10
11
/**
12
 * Class GithubPullRequestConverter.
13
 */
14 View Code Duplication
class GithubPullRequestConverter
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...
15
{
16
    use GithubPullRequestConvertTrait;
17
    use GithubCommitConvertTrait;
18
    use GithubMilestoneConvertTrait;
19
    use GithubUserConvertTrait;
20
    /**
21
     * @var GithubRepo
22
     */
23
    private $githubRepo;
24
25
    /**
26
     * GithubMilestoneConverter constructor.
27
     *
28
     * @param $githubRepo
29
     */
30
    public function __construct(GithubRepo $githubRepo)
31
    {
32
        $this->githubRepo = $githubRepo;
33
    }
34
35
    /**
36
     * @param $data
37
     *
38
     * @return \DevBoardLib\GithubCore\PullRequest\GithubPullRequestSource
39
     */
40
    public function convert($data)
41
    {
42
        return $this->convertPullRequest($data);
43
    }
44
45
    /**
46
     * @param $dateString
47
     *
48
     * @return DateTime|null
49
     */
50
    protected function getDateIfExists($dateString)
51
    {
52
        if (empty($dateString)) {
53
            return null;
54
        }
55
56
        return new DateTime($dateString);
57
    }
58
}
59