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

AdminManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 47
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getVersion() 0 8 1
A __construct() 0 3 1
A getRunningTransactions() 0 5 2
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