LaravelFreelancerNL /
laravel-arangodb
| 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
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
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
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 |