GithubCommitStatusConverter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 93.02 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 0
cbo 2
dl 40
loc 43
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\CommitStatus\Converter;
4
5
use DateTime;
6
use DevBoardLib\GithubCore\Repo\GithubRepo;
7
use DevBoardLib\GithubObjectApiFacade\User\Converter\GithubUserConvertTrait;
8
9
/**
10
 * Class GithubCommitStatusConverter.
11
 */
12 View Code Duplication
class GithubCommitStatusConverter
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...
13
{
14
    use GithubCommitStatusConvertTrait;
15
    use GithubUserConvertTrait;
16
    /**
17
     * @var GithubRepo
18
     */
19
    private $githubRepo;
20
21
    /**
22
     * GithubMilestoneConverter constructor.
23
     *
24
     * @param $githubRepo
25
     */
26
    public function __construct(GithubRepo $githubRepo)
27
    {
28
        $this->githubRepo = $githubRepo;
29
    }
30
31
    /**
32
     * @param $data
33
     *
34
     * @return \DevBoardLib\GithubCore\CommitStatus\GithubCommitStatusSource
35
     */
36
    public function convert($data)
37
    {
38
        return $this->convertCommitStatus($data);
39
    }
40
41
    /**
42
     * @param $dateString
43
     *
44
     * @return DateTime|null
45
     */
46
    protected function getDateIfExists($dateString)
47
    {
48
        if (empty($dateString)) {
49
            return null;
50
        }
51
52
        return new DateTime($dateString);
53
    }
54
}
55