Skip to content

Commit 130d036

Browse files
small refactor on Graph namespace
1 parent 552c907 commit 130d036

File tree

5 files changed

+17
-27
lines changed

5 files changed

+17
-27
lines changed

src/Database/DatabaseHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public static function userDatabases(Connection $connection): ArrayList
132132
* @return array An array with information about database.
133133
*
134134
* @throws GuzzleException|DatabaseException
135-
* @see https://www.arangodb.com/docs/stable/http/database-database-management.html#information-of-the-database
135+
* @see https://docs.arangodb.com/3.12/develop/http-api/databases/#get-information-about-the-current-database
136136
*/
137137
public static function current(Connection $connection): array
138138
{

src/Graph/Graph.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ public function __construct(string $name, array $attributes = [], Database $data
118118
$this->isNew = !(isset($attributes['_rev']) && isset($attributes['_id']));
119119

120120
// Set the given options or fallback to a default value.
121-
$this->id = isset($attributes['_id']) ? $attributes['_id'] : '';
122-
$this->revision = isset($attributes['_rev']) ? $attributes['_rev'] : '';
123-
$this->numberOfShards = isset($attributes['numberOfShards']) ? $attributes['numberOfShards'] : 1;
124-
$this->replicationFactor = isset($attributes['replicationFactor']) ? $attributes['replicationFactor'] : 1;
125-
$this->minReplicationFactor = isset($attributes['minReplicationFactor']) ? $attributes['minReplicationFactor'] : 1;
126-
$this->isSmart = isset($attributes['isSmart']) ? $attributes['isSmart'] : false;
127-
$this->orphanCollections = isset($attributes['orphanCollections']) ? $attributes['orphanCollections'] : [];
121+
$this->id = $attributes['_id'] ?? '';
122+
$this->revision = $attributes['_rev'] ?? '';
123+
$this->numberOfShards = $attributes['numberOfShards'] ?? 1;
124+
$this->replicationFactor = $attributes['replicationFactor'] ?? 1;
125+
$this->minReplicationFactor = $attributes['minReplicationFactor'] ?? 1;
126+
$this->isSmart = $attributes['isSmart'] ?? false;
127+
$this->orphanCollections = $attributes['orphanCollections'] ?? [];
128128
$this->edgeDefinitions = new ArrayList();
129129

130130
// Edge definitions passed as array.
@@ -301,9 +301,9 @@ public function save(): bool
301301
*
302302
* @return bool True if operation was successful, false otherwise.
303303
*
304-
* @throws DatabaseException|GuzzleException|ArangoException
304+
* @throws DatabaseException|GuzzleException
305305
*/
306-
public function delete($dropCollections = false): bool
306+
public function delete(bool $dropCollections = false): bool
307307
{
308308
try {
309309
if (!$this->database) {
@@ -319,7 +319,7 @@ public function delete($dropCollections = false): bool
319319
$uri = Api::buildSystemUri($connection->getBaseUri(), Api::GRAPH);
320320
$uri = Api::addUriParam($uri, $this->getName());
321321
$uri = $dropCollections ? Api::addQuery($uri, ['dropCollections' => $dropCollections]) : $uri;
322-
$response = $connection->delete($uri);
322+
$connection->delete($uri);
323323
return true;
324324
} catch (ClientException $exception) {
325325
$response = json_decode((string)$exception->getResponse()->getBody(), true);

src/Graph/Traversal/Traversal.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ class Traversal
2727
*
2828
* @var string
2929
*/
30-
public const GRAPH_DIRECTION_INBOUND = 'INBOUND';
30+
public const string GRAPH_DIRECTION_INBOUND = 'INBOUND';
3131

3232
/**
3333
* Outbound graph direction.
3434
*
3535
* @var string
3636
*/
37-
public const GRAPH_DIRECTION_OUTBOUND = 'OUTBOUND';
37+
public const string GRAPH_DIRECTION_OUTBOUND = 'OUTBOUND';
3838

3939
/**
4040
* Any graph direction.
4141
*
4242
* @var string
4343
*/
44-
public const GRAPH_DIRECTION_ANY = 'ANY';
44+
public const string GRAPH_DIRECTION_ANY = 'ANY';
4545

4646
/**
4747
* The traversal query
@@ -82,24 +82,14 @@ public function __construct(Statement $statement, Connection $connection = null)
8282
}
8383
}
8484

85-
/**
86-
* Sets a connection to use for traversal.
87-
*
88-
* @param Connection $connection
89-
*/
90-
public function setConnection(Connection $connection): void
91-
{
92-
$this->connection = $connection;
93-
}
94-
9585
/**
9686
* Returns the query,
9787
*
9888
* @return string
9989
*
10090
* @throws StatementException
10191
*/
102-
public function toAql()
92+
public function toAql(): string
10393
{
10494
return $this->statement->toAql();
10595
}

tests/Graph/Traversal/PathTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class PathTest extends BaseGraphTest
1414
{
15-
protected function mockData()
15+
protected function mockData(): array
1616
{
1717
return [
1818
'edges' => [

tests/Graph/Traversal/TraversalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ public function testTraversalQueryThrowException()
3232

3333
$this->expectException(Exception::class);
3434
$this->expectExceptionMessage("The given Vertex object hasn't a Connection set.");
35-
$traversal = Traversal::traversalQuery($vertex, "traversal_test_graph", Traversal::GRAPH_DIRECTION_OUTBOUND, 2);
35+
Traversal::traversalQuery($vertex, "traversal_test_graph", Traversal::GRAPH_DIRECTION_OUTBOUND, 2);
3636
}
3737
}

0 commit comments

Comments
 (0)