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

convertCommitStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 14
rs 9.4285
cc 1
eloc 10
nc 1
nop 1
1
<?php
2
namespace DevBoardLib\GithubObjectApiFacade\Repo\CommitStatus\Converter;
3
4
use DateTime;
5
use DevBoardLib\GithubCore\Commit\GithubCommitId;
6
use DevBoardLib\GithubCore\Commit\GithubCommitSha;
7
use DevBoardLib\GithubCore\CommitStatus\GithubCommitStatusId;
8
use DevBoardLib\GithubCore\CommitStatus\GithubCommitStatusSource;
9
use DevBoardLib\GithubCore\CommitStatus\State\GithubCommitStatusStateFactory;
10
use DevBoardLib\GithubCore\External\ExternalServiceId;
11
12
/**
13
 * Class GithubCommitStatusConvertTrait.
14
 */
15
trait GithubCommitStatusConvertTrait
16
{
17
    /**
18
     * @param $data
19
     *
20
     * @throws \Exception
21
     *
22
     * @return GithubCommitStatusSource
23
     */
24
    protected function convertCommitStatus($data)
25
    {
26
        return new GithubCommitStatusSource(
27
            new GithubCommitStatusId($data['id']),
28
            new GithubCommitId($this->githubRepo->getId(), new GithubCommitSha($data['sha'])),
0 ignored issues
show
Bug introduced by
The property githubRepo does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
29
            new ExternalServiceId($data['context']),
30
            $data['description'],
31
            $data['target_url'],
32
            GithubCommitStatusStateFactory::create($data['state']),
33
            new DateTime($data['created_at']),
34
            new DateTime($data['updated_at'])
35
36
        );
37
    }
38
}
39