Passed
Pull Request — master (#1)
by Jérémy
01:49
created

User::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JDecool\Clockify\Api\User;
6
7
use JDecool\Clockify\Api\Client\Client;
8
use JDecool\Clockify\Model\CurrentUserDto;
9
use JDecool\Clockify\Model\UserDto;
10
11
class User
12
{
13
    private $http;
14
15
    public function __construct(Client $http)
16
    {
17
        $this->http = $http;
18
    }
19
20
    public function current(): CurrentUserDto
21
    {
22
        $data = $this->http->get("/user");
0 ignored issues
show
Bug introduced by
The method get() does not exist on JDecool\Clockify\Api\Client\Client. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        /** @scrutinizer ignore-call */ 
23
        $data = $this->http->get("/user");

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
24
        return CurrentUserDto::fromArray($data);
25
    }
26
27
    /**
28
     * @return UserDto[]
29
     */
30
    public function workspaceUsers(string $workspaceId): array
31
    {
32
        $data = $this->http->get("/workspace/$workspaceId/users");
33
34
        return array_map(
35
            static function(array $user): UserDto {
36
                return UserDto::fromArray($user);
37
            },
38
            $data
39
        );
40
    }
41
}
42