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

GithubTagConverter::convert()   A

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
namespace DevBoardLib\GithubObjectApiFacade\Repo\Tag\Converter;
3
4
use DateTime;
5
use DevBoardLib\GithubCore\Repo\GithubRepo;
6
use DevBoardLib\GithubObjectApiFacade\Repo\Commit\Converter\GithubCommitConvertTrait;
7
use DevBoardLib\GithubObjectApiFacade\User\Converter\GithubUserConvertTrait;
8
9
/**
10
 * Class GithubTagConverter.
11
 */
12 View Code Duplication
class GithubTagConverter
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 GithubTagConvertTrait;
15
    use GithubCommitConvertTrait;
16
    use GithubUserConvertTrait;
17
    private $githubRepo;
18
19
    /**
20
     * GithubMilestoneConverter constructor.
21
     *
22
     * @param $githubRepo
23
     */
24
    public function __construct(GithubRepo $githubRepo)
25
    {
26
        $this->githubRepo = $githubRepo;
27
    }
28
29
    /**
30
     * @param $data
31
     *
32
     * @return \DevBoardLib\GithubCore\Tag\GithubTagSource
33
     */
34
    public function convert($data)
35
    {
36
        return $this->convertTag($data);
37
    }
38
39
    /**
40
     * @param $dateString
41
     *
42
     * @return DateTime|null
43
     */
44
    protected function getDateIfExists($dateString)
45
    {
46
        if (empty($dateString)) {
47
            return null;
48
        }
49
50
        return new DateTime($dateString);
51
    }
52
}
53