Completed
Push — 121-support-joinlateral ( b4e6e6 )
by Bas
18s queued 16s
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
     * @param string $name
31
     * @return mixed[]
32
     * @throws ArangoException
33
     */
34
    public function getGraph(string $name): array
35
    {
36
        return (array) $this->schemaManager->getGraph($name);
37
    }
38
39
    /**
40
     * @return mixed[]
41
     * @throws ArangoException
42
     */
43 8
    public function getGraphs(): array
44
    {
45 8
        return $this->mapResultsToArray(
0 ignored issues
show
Bug introduced by
It seems like mapResultsToArray() 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

45
        return $this->/** @scrutinizer ignore-call */ mapResultsToArray(
Loading history...
46 8
            $this->schemaManager->getGraphs(),
47 8
        );
48
    }
49
50
    /**
51
     * @throws ArangoException
52
     */
53 1
    public function dropGraph(string $name)
54
    {
55 1
        $this->schemaManager->deleteGraph($name);
56
    }
57
58
    /**
59
     * @throws ArangoException
60
     */
61 2
    public function dropGraphIfExists(string $name): bool
62
    {
63 2
        if ($this->hasGraph($name)) {
64 1
            $this->schemaManager->deleteGraph($name);
65
        }
66
67 2
        return true;
68
    }
69
70 35
    public function dropAllGraphs(): void
71
    {
72 35
        $this->schemaManager->deleteAllGraphs();
73
    }
74
}
75