Completed
Pull Request — master (#8)
by Miro
03:40
created

GithubPullRequestConverter::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\PullRequest\Converter;
3
4
use DateTime;
5
use DevBoardLib\GithubCore\Repo\GithubRepo;
6
use DevBoardLib\GithubObjectApiFacade\Repo\Commit\Converter\GithubCommitConvertTrait;
7
use DevBoardLib\GithubObjectApiFacade\Repo\Milestone\Converter\GithubMilestoneConvertTrait;
8
use DevBoardLib\GithubObjectApiFacade\User\Converter\GithubUserConvertTrait;
9
10
/**
11
 * Class GithubPullRequestConverter.
12
 */
13 View Code Duplication
class GithubPullRequestConverter
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 GithubPullRequestConvertTrait;
16
    use GithubCommitConvertTrait;
17
    use GithubMilestoneConvertTrait;
18
    use GithubUserConvertTrait;
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\PullRequest\GithubPullRequestSource
35
     */
36
    public function convert($data)
37
    {
38
        return $this->convertPullRequest($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