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

AdminManager::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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