User   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 27
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A current() 0 5 1
A workspaceUsers() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JDecool\Clockify\Api\User;
6
7
use JDecool\Clockify\{
8
    Client,
9
    Model\CurrentUserDto,
10
    Model\UserDto
11
};
12
13
class User
14
{
15
    private $http;
16
17
    public function __construct(Client $http)
18
    {
19
        $this->http = $http;
20
    }
21
22
    public function current(): CurrentUserDto
23
    {
24
        $data = $this->http->get("/user");
25
26
        return CurrentUserDto::fromArray($data);
27
    }
28
29
    /**
30
     * @return UserDto[]
31
     */
32
    public function workspaceUsers(string $workspaceId): array
33
    {
34
        $data = $this->http->get("/workspaces/$workspaceId/users");
35
        return array_map(
36
            static function(array $user): UserDto {
37
                return UserDto::fromArray($user);
38
            },
39
            $data
40
        );
41
    }
42
}
43