Completed
Push — master ( 3e5383...5237e6 )
by Miro
02:50
created

src/Repo/Repo/Converter/GithubRepoConvertTrait.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace DevBoardLib\GithubObjectApiFacade\Repo\Repo\Converter;
4
5
use DateTime;
6
use DevBoardLib\GithubCore\Repo\GithubRepoId;
7
use DevBoardLib\GithubCore\Repo\GithubRepoPermissions;
8
use DevBoardLib\GithubCore\Repo\GithubRepoSource;
9
10
/**
11
 * Class GithubRepoConvertTrait.
12
 */
13
trait GithubRepoConvertTrait
14
{
15
    /**
16
     * @param array $data
17
     *
18
     * @return GithubRepoSource
19
     */
20
    protected function convertRepo(array $data)
21
    {
22
        $permissions = null;
23
24
        if (array_key_exists('permissions', $data)) {
25
            $permissions = new GithubRepoPermissions(
26
                (bool) $data['permissions']['admin'],
27
                (bool) $data['permissions']['push'],
28
                (bool) $data['permissions']['pull']
29
            );
30
        }
31
32
        return new GithubRepoSource(
33
            new GithubRepoId($data['id']),
34
            $this->getUser($data['owner']),
0 ignored issues
show
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...
35
            $data['owner']['login'],
36
            $data['name'],
37
            $data['full_name'],
38
            $data['html_url'],
39
            $data['description'],
40
            $data['fork'],
41
            $data['default_branch'],
42
            $data['private'],
43
            $data['git_url'],
44
            $data['ssh_url'],
45
            $permissions,
46
            new DateTime($data['created_at']),
47
            new DateTime($data['updated_at']),
48
            new DateTime($data['pushed_at'])
49
        );
50
    }
51
}
52