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

GithubCommitStatusConvertTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 1
cbo 6
dl 0
loc 24
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A convertCommitStatus() 0 14 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