StatSubAccounts   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 33
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A list() 0 27 3
1
<?php
2
3
namespace SchulzeFelix\Stat\Api;
4
5
use Illuminate\Support\Collection;
6
use SchulzeFelix\Stat\Objects\StatSubAccount;
7
8
class StatSubAccounts extends BaseStat
9
{
10
    /**
11
     * @return Collection
12
     */
13
    public function list(): Collection
14
    {
15
        $response = $this->performQuery('subaccounts/list');
16
17
        $subaccounts = collect();
18
19
        if (! isset($response['User'])) {
20
            return $subaccounts;
21
        }
22
23
        if (isset($response['User']['Id'])) {
24
            $subaccounts->push($response['User']);
25
        } else {
26
            $subaccounts = collect($response['User']);
27
        }
28
29
        $subaccounts->transform(function ($item, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
            return new StatSubAccount([
31
                'id' => $item['Id'],
32
                'login' => $item['Login'],
33
                'api_key' => $item['ApiKey'],
34
                'created_at' => $item['CreatedAt'],
35
            ]);
36
        });
37
38
        return $subaccounts;
39
    }
40
}
41