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

GithubUserConvertTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getUser() 0 11 1
A getUserIfExists() 0 8 2
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