Passed
Push — master ( 6aff30...239879 )
by Thijs
09:39
created

TransformsAccounts   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromDevOpsAccounts() 0 7 1
A fromDevOpsAccount() 0 7 1
1
<?php
2
3
namespace TestMonitor\DevOps\Transforms;
4
5
use TestMonitor\DevOps\Validator;
6
use TestMonitor\DevOps\Resources\Account;
7
8
trait TransformsAccounts
9
{
10
    /**
11
     * @param array $accounts
12
     *
13
     * @throws \TestMonitor\DevOps\Exceptions\InvalidDataException
14
     *
15
     * @return \TestMonitor\DevOps\Resources\Account[]
16
     */
17 1
    protected function fromDevOpsAccounts($accounts): array
18
    {
19 1
        Validator::isArray($accounts);
20
21 1
        return array_map(function ($account) {
22 1
            return $this->fromDevOpsAccount($account);
23 1
        }, $accounts);
24
    }
25
26
    /**
27
     * @param array $account
28
     *
29
     * @throws \TestMonitor\DevOps\Exceptions\InvalidDataException
30
     *
31
     * @return \TestMonitor\DevOps\Resources\Account
32
     */
33 1
    protected function fromDevOpsAccount($account): Account
34
    {
35 1
        Validator::keysExists($account, ['AccountId', 'AccountName']);
36
37 1
        return new Account([
38 1
            'id' => $account['AccountId'],
39 1
            'name' => $account['AccountName'],
40
        ]);
41
    }
42
}
43