Completed
Push — master ( f0e2f6...92b1b1 )
by Thijs
01:21
created

ManagesAccounts::accounts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1.1623

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 5
cts 11
cp 0.4545
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1.1623
1
<?php
2
3
namespace TestMonitor\DevOps\Actions;
4
5
use TestMonitor\DevOps\Transforms\TransformsAccounts;
6
7
trait ManagesAccounts
8
{
9
    use TransformsAccounts;
10
11
    /**
12
     * Get a list of of accounts.
13
     *
14
     * @return \TestMonitor\DevOps\Resources\Account[]
15
     */
16 1
    public function accounts()
17
    {
18 1
        $connection = $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?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
19 1
            'GET',
20 1
            'https://app.vssps.visualstudio.com/_apis/ConnectionData',
21 1
            ['query' => ['api-version' => '5.0-preview'], 'debug' => true]
22
        );
23
24
        // 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?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
26
            'GET',
27
            'https://app.vssps.visualstudio.com/_apis/accounts',
28
            ['query' => ['memberId' => $connection['authenticatedUser']['id']]]
29
        );
30
31
        return array_map(function ($account) {
32
            return $this->fromDevOpsAccount($account);
33
        }, $accounts);
34
    }
35
}
36