Passed
Push — next ( 381d12...e3594a )
by Bas
05:57
created

HandlesGraphs::getGraph()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 1
b 0
f 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\Aranguent\Schema\Concerns;
6
7
use ArangoClient\Exceptions\ArangoException;
8
9
trait HandlesGraphs
10
{
11
    /**
12
     * @param  array<mixed>  $properties
13
     * @throws ArangoException
14
     *
15
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
16
     */
17 8
    public function createGraph(string $name, array $properties = [], bool $waitForSync = false)
18
    {
19 8
        $this->schemaManager->createGraph($name, $properties, $waitForSync);
20
    }
21
22 2
    public function hasGraph(string $name): bool
23
    {
24 2
        return $this->handleExceptionsAsQueryExceptions(function () use ($name) {
0 ignored issues
show
Bug introduced by
It seems like handleExceptionsAsQueryExceptions() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        return $this->/** @scrutinizer ignore-call */ handleExceptionsAsQueryExceptions(function () use ($name) {
Loading history...
25 2
            return $this->schemaManager->hasGraph($name);
26 2
        });
27
    }
28
29
    /**
30
     * @throws ArangoException
31
     */
32
    public function getGraph(string $name): \stdClass
33
    {
34
        return $this->schemaManager->getGraph($name);
35
    }
36
37
    /**
38
     * @throws ArangoException
39
     */
40 8
    public function getGraphs(): array
41
    {
42 8
        return $this->schemaManager->getGraphs();
43
    }
44
45
    /**
46
     * @throws ArangoException
47
     */
48 1
    public function dropGraph(string $name)
49
    {
50 1
        $this->schemaManager->deleteGraph($name);
51
    }
52
53
    /**
54
     * @throws ArangoException
55
     */
56 2
    public function dropGraphIfExists(string $name): bool
57
    {
58 2
        if ($this->hasGraph($name)) {
59 1
            $this->schemaManager->deleteGraph($name);
60
        }
61
62 2
        return true;
63
    }
64
65 35
    public function dropAllGraphs(): void
66
    {
67 35
        $this->schemaManager->deleteAllGraphs();
68
    }
69
}
70