Passed
Push — master ( 4a97f2...e97872 )
by Thijs
10:20
created

ManagesAccounts::myself()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
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 member ID
22 7
        $connection = $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

22
        /** @scrutinizer ignore-call */ 
23
        $connection = $this->get('https://app.vssps.visualstudio.com/_apis/profile/profiles/me');
Loading history...
23
24 1
        Validator::keyExists($connection, 'id');
25
26
        // Second, retrieve for the accounts for this member
27 1
        $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

27
        /** @scrutinizer ignore-call */ 
28
        $accounts = $this->request(
Loading history...
28 1
            'GET',
29 1
            'https://app.vssps.visualstudio.com/_apis/accounts',
30 1
            ['query' => ['memberId' => $connection['id']]]
31 1
        );
32
33 1
        return $this->fromDevOpsAccounts($accounts);
34
    }
35
}
36