GithubIssueConverter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 70.45 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 4
c 3
b 0
f 2
lcom 0
cbo 3
dl 31
loc 44
rs 10

3 Methods

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