Failed Conditions
Push — next ( 580d6f...1a59b4 )
by Bas
02:36
created

AdminManager::getVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
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 5
cts 5
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
11
class AdminManager extends Manager
12
{
13
    /**
14
     * @var ArangoClient
15
     */
16
    protected ArangoClient $arangoClient;
17
18
    /**
19
     * Documents constructor.
20
     * @param  ArangoClient  $arangoClient
21
     */
22 76
    public function __construct(ArangoClient $arangoClient)
23
    {
24 76
        $this->arangoClient = $arangoClient;
25 76
    }
26
27
    /**
28
     *
29
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
30
     *
31
     * @param  bool  $details
32
     * @return array<mixed>
33
     *
34
     * @throws ArangoException
35
     */
36 3
    public function getVersion(bool $details = false): array
37
    {
38 3
        return $this->arangoClient->request(
39 3
            'get',
40 3
            '/_api/version',
41
            [
42
                'query' => [
43 3
                    'details' => $details
44
                ]
45
            ]
46
        );
47
    }
48
49
    /**
50
     * @return array<mixed>
51
     * @throws ArangoException
52
     */
53 8
    public function getRunningTransactions(): array
54
    {
55 8
        $result = $this->arangoClient->request('get', '/_api/transaction');
56
57 8
        return (isset($result['transactions'])) ? (array) $result['transactions'] : [];
58
    }
59
}
60