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

AdminManager::getRunningTransactions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

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