AdminManager   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 32
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getVersion() 0 8 1
A getRunningTransactions() 0 5 3
A __construct() 0 1 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
    public function __construct(protected ArangoClient $arangoClient) {}
15
16
    /**
17
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
18
     *
19
     * @throws ArangoException
20
     */
21 3
    public function getVersion(bool $details = false): stdClass
22
    {
23 3
        return $this->arangoClient->request(
24 3
            'get',
25 3
            '/_api/version',
26 3
            [
27 3
                'query' => [
28 3
                    'details' => $details,
29 3
                ],
30 3
            ],
31 3
        );
32
    }
33
34
    /**
35
     * @return array<mixed>
36
     *
37
     * @throws ArangoException
38
     */
39 9
    public function getRunningTransactions(): array
40
    {
41 9
        $result = $this->arangoClient->request('get', '/_api/transaction');
42
43 9
        return (property_exists($result, 'transactions') && $result->transactions !== null) ? (array) $result->transactions : [];
44
    }
45
}
46