GithubCommitStatusConverter::convert()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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