Completed
Push — master ( bdfdc7...772f65 )
by Kirill
02:27
created

GitterUser::setAvatar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * This file is part of Platform package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Karma\System\Gitter;
11
12
use Karma\Platform\Io\AbstractUser;
13
use Karma\Platform\Io\SystemInterface;
14
15
/**
16
 * Class GitterUser
17
 * @package Karma\System\Gitter
18
 */
19
class GitterUser extends AbstractUser
20
{
21
    /**
22
     * GitterUser constructor.
23
     * @param SystemInterface $system
24
     * @param array $data
25
     */
26
    public function __construct(SystemInterface $system, array $data)
27
    {
28
        $id    = $data['id'] ?? $data['userId'];
29
        $login = $data['username'] ?? $data['displayName'] ?? $data['screenName'];
30
31
        parent::__construct($system, $id, $login);
32
33
        $this->avatar = $data['avatarUrl'] ?? null;
34
    }
35
36
    /**
37
     * @param string $newName
38
     */
39
    public function rename(string $newName): void
40
    {
41
        $this->name = $newName;
42
    }
43
44
    /**
45
     * @param null|string $avatar
46
     */
47
    public function setAvatar(?string $avatar): void
48
    {
49
        $this->avatar = $avatar;
50
    }
51
}
52