User::current()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
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