Completed
Push — master ( 84bf1d...fc2ff6 )
by Miro
03:05
created

GithubCommitStatusConverter::getDateIfExists()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Importance

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