Passed
Pull Request — master (#26)
by Thijs
09:57
created

ManagesAccounts::accounts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
ccs 8
cts 8
cp 1
crap 1
rs 10
1
<?php
2
3
namespace TestMonitor\DevOps\Actions;
4
5
use TestMonitor\DevOps\Validator;
6
use TestMonitor\DevOps\Transforms\TransformsAccounts;
7
8
trait ManagesAccounts
9
{
10
    use TransformsAccounts;
11
12
    /**
13
     * Get a list of of accounts.
14
     *
15
     * @throws \TestMonitor\DevOps\Exceptions\InvalidDataException
16
     *
17
     * @return \TestMonitor\DevOps\Resources\Account[]
18
     */
19 7
    public function accounts()
20
    {
21
        // First, establish your profile ID
22 7
        $user = $this->myself();
23
24 1
        // Second, retrieve for the accounts for this member
25
        $accounts = $this->request(
0 ignored issues
show
Bug introduced by
It seems like request() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

25
        /** @scrutinizer ignore-call */ 
26
        $accounts = $this->request(
Loading history...
26
            'GET',
27 1
            'https://app.vssps.visualstudio.com/_apis/accounts',
28 1
            ['query' => ['memberId' => $user->id]]
29 1
        );
30 1
31 1
        return $this->fromDevOpsAccounts($accounts);
32
    }
33 1
34
    /**
35
     * Returns the profile of the authenticated user.
36
     *
37
     * @return \TestMonitor\DevOps\Resources\Profile
38
     */
39
    public function myself()
40
    {
41
        $response = $this->get('https://app.vssps.visualstudio.com/_apis/profile/profiles/me');
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

41
        /** @scrutinizer ignore-call */ 
42
        $response = $this->get('https://app.vssps.visualstudio.com/_apis/profile/profiles/me');
Loading history...
42
43
        return $this->fromDevOpsProfile($response);
44
    }
45
}
46