Completed
Push — master ( b812a3...c78ccd )
by Thijs
10:26 queued 08:16
created

ManagesAccounts::accounts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 11
cts 11
cp 1
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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 6
    public function accounts()
17
    {
18 6
        $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 6
            'GET',
20 6
            'https://app.vssps.visualstudio.com/_apis/ConnectionData',
21 6
            ['query' => ['api-version' => '5.0-preview'], 'debug' => true]
22
        );
23
24
        // Second, retrieve for the accounts for this member
25 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?

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