AdminManager::getVersion()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 8
ccs 7
cts 7
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
    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