diff --git a/src/Core/DeegraphServer.php b/src/Core/DeegraphServer.php index cf1e77f..5494587 100644 --- a/src/Core/DeegraphServer.php +++ b/src/Core/DeegraphServer.php @@ -42,7 +42,7 @@ class DeegraphServer * * @throws Exception */ - private function RunRawRequest( + private function runRawRequest( UUID $actorID, string $endpoint, string $method = "GET", @@ -128,7 +128,7 @@ class DeegraphServer message: "Deegraph server responded with an internal error code", code: 0, previous: null, - // trade: isset($server_output["@trace"]) ? $server_output["@trace"] : null + // trade: isset($server_output["@trace"]) ? $server_output["@trace"] : null ); } @@ -140,9 +140,9 @@ class DeegraphServer return $temp; } - public function RunQuery(UUID $actorID, string $queryString): array + public function runQuery(UUID $actorID, string $queryString): array { - return $this->RunRawRequest( + return $this->runRawRequest( actorID: $actorID, endpoint: "/api/v1/@query", method: "POST", @@ -150,9 +150,9 @@ class DeegraphServer ); } - public function GetRawNode(UUID $actorID, UUID $nodeID): DeegraphNodeDetails + public function getRawNode(UUID $actorID, UUID $nodeID): DeegraphNodeDetails { - $response = $this->RunRawRequest( + $response = $this->runRawRequest( actorID: $actorID, endpoint: "/api/v1/{$nodeID}", method: "GET", @@ -165,9 +165,9 @@ class DeegraphServer * Runs an API request against the Deegraph Server, and returns back information about the Deegraph Server. * @return ServerInfo */ - public function ServerInfo(UUID $actorID): ServerInfo + public function serverInfo(UUID $actorID): ServerInfo { - $response = $this->RunRawRequest( + $response = $this->runRawRequest( actorID: $actorID, endpoint: "/api/v1/@server_info", method: "GET", @@ -177,9 +177,9 @@ class DeegraphServer } - public function CreateNewNode( + public function createNewNode( UUID $actorID, - string $dataURL, + ?string $dataURL = null, ?string $schema = null, ?UUID $creator = null ): NewNodeDetails @@ -190,7 +190,7 @@ class DeegraphServer if($schema != null) $body["@schema"] = $schema; - $response = $this->RunRawRequest( + $response = $this->runRawRequest( actorID: $actorID, endpoint: "/api/v1/@new", method: "PUT", diff --git a/src/QueryBuilder/QueryBuilderTrait.php b/src/QueryBuilder/QueryBuilderTrait.php index 3c3c283..4ce307a 100755 --- a/src/QueryBuilder/QueryBuilderTrait.php +++ b/src/QueryBuilder/QueryBuilderTrait.php @@ -21,28 +21,28 @@ use ReflectionClass; trait QueryBuilderTrait { - protected function RegexValidate(string $target, string $pattern): string + protected function regexValidate(string $target, string $pattern): string { if (!preg_match(pattern: $pattern, subject: $target)) throw new QueryBuilderInvalidInputException(); return $target; } - protected function EnsureNotSet(string $target): void + protected function ensureNotSet(string $target): void { if ($target != "") throw new QueryBuilderConflictingFieldAlreadyExistsException(); } - protected function ValidateDeegraphPath(string $target): string + protected function validateDeegraphPath(string $target): string { - if (!RelativePath::Validate($target)) + if (!RelativePath::validate($target)) throw new QueryBuilderInvalidInputException(); return $target; } - protected function ValidateValues( + public function validateValues( DeleteQueryBuilder |DirectoryQueryBuilder |InsertQueryBuilder diff --git a/src/QueryBuilder/ReferencesQuery/ReferencesQueryResponse.php b/src/QueryBuilder/ReferencesQuery/ReferencesQueryResponse.php index c67bae4..92e915a 100644 --- a/src/QueryBuilder/ReferencesQuery/ReferencesQueryResponse.php +++ b/src/QueryBuilder/ReferencesQuery/ReferencesQueryResponse.php @@ -5,9 +5,20 @@ namespace Darksparrow\DeegraphInteractions\QueryBuilder\ReferencesQuery; class ReferencesQueryResponse { public array $Map; + public int $Count; + public function __construct(array $deegraphResponse) { - $this->Map = $deegraphResponse["@map"]; + if(isset($deegraphResponse["Map"])) + { + $this->Map = $deegraphResponse["@map"]; + $this->Count = sizeof($this->Map); + } + else + { + $this->Map = []; + $this->Count = 0; + } } } diff --git a/tests/QueryBuilderPermissionsTest.php b/tests/QueryBuilderPermissionsTest.php index a407c30..1c1d17b 100644 --- a/tests/QueryBuilderPermissionsTest.php +++ b/tests/QueryBuilderPermissionsTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; final class QueryBuilderPermissionsTest extends TestCase { - public function testReferenceQuery() + public function testPermissionQuery() { $query = QueryBuilder::Permission() ->on("{00000000-0000-0000-0000-000000000000}")