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 HandlesIndexes |
||||
| 10 | { |
||||
| 11 | /** |
||||
| 12 | * Determine if the given table has a given index. |
||||
| 13 | * |
||||
| 14 | * @param string $table |
||||
| 15 | * @param string|array<string> $index |
||||
| 16 | * @param string|null $type |
||||
| 17 | * @return bool |
||||
| 18 | */ |
||||
| 19 | 2 | public function hasIndex($table, $index, $type = null, array $options = []) |
|||
| 20 | { |
||||
| 21 | 2 | $name = $index; |
|||
| 22 | |||||
| 23 | 2 | if ($type === null) { |
|||
| 24 | 2 | $type = 'persistent'; |
|||
| 25 | } |
||||
| 26 | |||||
| 27 | 2 | if (is_array($index)) { |
|||
| 28 | 1 | $name = $this->createIndexName($type, $index, $options, $table); |
|||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 29 | } |
||||
| 30 | |||||
| 31 | 2 | return !!$this->schemaManager->getIndexByName($table, $name); |
|||
| 32 | } |
||||
| 33 | |||||
| 34 | /** |
||||
| 35 | * @param string $id |
||||
| 36 | * @return array<mixed> |
||||
| 37 | */ |
||||
| 38 | public function getIndex(string $id) |
||||
| 39 | { |
||||
| 40 | return (array) $this->schemaManager->getIndex($id); |
||||
| 41 | } |
||||
| 42 | |||||
| 43 | /** |
||||
| 44 | * @param string $table |
||||
| 45 | * @return mixed[] |
||||
| 46 | * @throws ArangoException |
||||
| 47 | */ |
||||
| 48 | 8 | public function getIndexes($table) |
|||
| 49 | { |
||||
| 50 | 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...
|
|||||
| 51 | 8 | $this->schemaManager->getIndexes($table), |
|||
| 52 | 8 | ); |
|||
| 53 | } |
||||
| 54 | } |
||||
| 55 |