Passed
Push — remanufacture/json-object-deco... ( 07d964...ba9553 )
by Bas
03:04 queued 01:15
created

AdminManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 41
ccs 11
cts 11
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getVersion() 0 9 1
A getRunningTransactions() 0 5 2
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ArangoClient\Admin;
6
7
use ArangoClient\ArangoClient;
8
use ArangoClient\Exceptions\ArangoException;
9
use ArangoClient\Manager;
10
use stdClass;
11
12
class AdminManager extends Manager
13
{
14
    protected ArangoClient $arangoClient;
15
16 104
    public function __construct(ArangoClient $arangoClient)
17
    {
18 104
        $this->arangoClient = $arangoClient;
19 104
    }
20
21
    /**
22
     *
23
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
24
     *
25
     * @param  bool  $details
26
     * @return stdClass
27
     *
28
     * @throws ArangoException
29
     */
30 3
    public function getVersion(bool $details = false): stdClass
31
    {
32
33 3
        return $this->arangoClient->request(
34 3
            'get',
35 3
            '/_api/version',
36
            [
37
                'query' => [
38 3
                    'details' => $details
39
                ]
40
            ]
41
        );
42
    }
43
44
    /**
45
     * @return array<mixed>
46
     * @throws ArangoException
47
     */
48 9
    public function getRunningTransactions(): array
49
    {
50 9
        $result = $this->arangoClient->request('get', '/_api/transaction');
51
52 9
        return (isset($result->transactions)) ? (array) $result->transactions : [];
53
    }
54
}
55