GithubMilestoneConverter::getDateIfExists()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace DevBoardLib\GithubObjectApiFacade\Repo\Milestone\Converter;
4
5
use DateTime;
6
use DevBoardLib\GithubCore\Repo\GithubRepo;
7
use DevBoardLib\GithubObjectApiFacade\User\Converter\GithubUserConvertTrait;
8
9
/**
10
 * Class GithubMilestoneConverter.
11
 */
12 View Code Duplication
class GithubMilestoneConverter
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 GithubMilestoneConvertTrait;
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 array $data
33
     *
34
     * @return \DevBoardLib\GithubCore\Milestone\GithubMilestoneSource
35
     */
36
    public function convert(array $data)
37
    {
38
        return $this->convertMilestone($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