Completed
Push — master ( 12f683...a4b1f6 )
by Miro
02:18
created

GithubUserConvertTrait::getUserIfExists()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
namespace DevBoardLib\GithubObjectApiFacade\User\Converter;
3
4
use DevBoardLib\GithubCore\User\GithubUserId;
5
use DevBoardLib\GithubObjectApiFacade\User\GithubUserSource;
6
7
trait GithubUserConvertTrait
8
{
9
    protected function getUser($data)
10
    {
11
        return new GithubUserSource(
12
            new GithubUserId($data['id']),
13
            $data['login'],
14
            null,
15
            null,
16
            $data['avatar_url']
17
18
        );
19
    }
20
21
    protected function getUserIfExists($data)
22
    {
23
        if (empty($data)) {
24
            return null;
25
        }
26
27
        return $this->getUser($data);
28
    }
29
}
30