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

GithubRepoConvertTrait::convertRepo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 20
rs 9.4285
cc 1
eloc 17
nc 1
nop 1
1
<?php
2
namespace DevBoardLib\GithubObjectApiFacade\Repo\Repo\Converter;
3
4
use DateTime;
5
use DevBoardLib\GithubCore\Repo\GithubRepoId;
6
use DevBoardLib\GithubCore\Repo\GithubRepoSource;
7
8
/**
9
 * Class GithubRepoConvertTrait.
10
 */
11
trait GithubRepoConvertTrait
12
{
13
    /**
14
     * @param $data
15
     *
16
     * @return GithubRepoSource
17
     */
18
    protected function convertRepo($data)
19
    {
20
        return new GithubRepoSource(
21
            new GithubRepoId($data['id']),
22
            $this->getUser($data['owner']),
0 ignored issues
show
Bug introduced by
It seems like getUser() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
23
            $data['owner']['login'],
24
            $data['name'],
25
            $data['full_name'],
26
            $data['html_url'],
27
            $data['description'],
28
            $data['fork'],
29
            $data['default_branch'],
30
            $data['private'],
31
            $data['git_url'],
32
            $data['ssh_url'],
33
            new DateTime($data['created_at']),
34
            new DateTime($data['updated_at']),
35
            new DateTime($data['pushed_at'])
36
        );
37
    }
38
}
39