Browse Source

capitalisation fixes

dev
Cerys 1 month ago
parent
commit
c4fba80a3c
  1. 6
      examples/QueryExample_Directory.php
  2. 6
      examples/QueryExample_Permission.php
  3. 6
      examples/QueryExample_References.php
  4. 8
      examples/QueryExample_Select.php
  5. 6
      src/DataStructures/DataURL.php
  6. 2
      src/DataStructures/DeegraphNodeDetails.php
  7. 2
      src/DataStructures/UUID.php
  8. 4
      src/QueryBuilder/DeleteQuery/DeleteQuery.php
  9. 8
      src/QueryBuilder/DeleteQuery/DeleteQueryBuilder.php
  10. 4
      src/QueryBuilder/DirectoryQuery/DirectoryQuery.php
  11. 8
      src/QueryBuilder/DirectoryQuery/DirectoryQueryBuilder.php
  12. 16
      src/QueryBuilder/InsertQuery/InsertQueryBuilder.php
  13. 2
      src/QueryBuilder/InsertQuery/InsertQueryBuilderInterface.php
  14. 4
      src/QueryBuilder/LinkQuery/LinkQuery.php
  15. 38
      src/QueryBuilder/LinkQuery/LinkQueryBuilder.php
  16. 4
      src/QueryBuilder/PermissionsQuery/PermissionQuery.php
  17. 8
      src/QueryBuilder/PermissionsQuery/PermissionQueryBuilder.php
  18. 2
      src/QueryBuilder/PermissionsQuery/PermissionQueryBuilderInterface.php
  19. 2
      src/QueryBuilder/PermissionsQuery/PermissionQueryResponse.php
  20. 26
      src/QueryBuilder/PutQuery/PutQueryBuilder.php
  21. 4
      src/QueryBuilder/ReferencesQuery/ReferencesQuery.php
  22. 8
      src/QueryBuilder/ReferencesQuery/ReferencesQueryBuilder.php
  23. 4
      src/QueryBuilder/SelectQuery/SelectQuery.php
  24. 12
      src/QueryBuilder/SelectQuery/SelectQueryBuilder.php
  25. 2
      src/QueryBuilder/SelectQuery/SelectQueryBuilderInterface.php
  26. 4
      src/QueryBuilder/UnlinkQuery/UnlinkQuery.php
  27. 14
      src/QueryBuilder/UnlinkQuery/UnlinkQueryBuilder.php
  28. 2
      src/Utilities/RelativePath.php
  29. 4
      tests/QueryBuilderDeleteTest.php
  30. 4
      tests/QueryBuilderDirectoryTest.php
  31. 48
      tests/QueryBuilderLinkTest.php
  32. 4
      tests/QueryBuilderPermissionsTest.php
  33. 14
      tests/QueryBuilderPutTest.php
  34. 4
      tests/QueryBuilderReferencesTest.php
  35. 12
      tests/QueryBuilderSelectTest.php
  36. 20
      tests/QueryBuilderUnlinkTest.php
  37. 6
      tests/ValidateDeegraphPathTest.php

6
examples/QueryExample_Directory.php

@ -7,9 +7,9 @@ use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder;
$result = QueryBuilder::Directory() $result = QueryBuilder::Directory()
->RelativePath("{0b368d41-7c15-42c8-899c-2b178ae9d983}") ->relativePath("{0b368d41-7c15-42c8-899c-2b178ae9d983}")
->Build() ->build()
->RunQuery( ->runQuery(
actorID: DeegraphConnection::Actor(), actorID: DeegraphConnection::Actor(),
server: DeegraphConnection::DB(), server: DeegraphConnection::DB(),
) )

6
examples/QueryExample_Permission.php

@ -7,9 +7,9 @@ use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder;
$permissions = QueryBuilder::Permission() $permissions = QueryBuilder::Permission()
->On("{b222c121-0ed2-5819-bbf9-4db9aab85ea3}") ->on("{b222c121-0ed2-5819-bbf9-4db9aab85ea3}")
->Build() ->build()
->RunQuery( ->runQuery(
actorID: DeegraphConnection::Actor(), actorID: DeegraphConnection::Actor(),
server: DeegraphConnection::DB(), server: DeegraphConnection::DB(),
) )

6
examples/QueryExample_References.php

@ -7,9 +7,9 @@ use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder;
$result = QueryBuilder::References() $result = QueryBuilder::References()
->RelativePath("{0b368d41-7c15-42c8-899c-2b178ae9d983}") ->relativePath("{0b368d41-7c15-42c8-899c-2b178ae9d983}")
->Build() ->build()
->RunQuery( ->runQuery(
actorID: DeegraphConnection::Actor(), actorID: DeegraphConnection::Actor(),
server: DeegraphConnection::DB(), server: DeegraphConnection::DB(),
) )

8
examples/QueryExample_Select.php

@ -9,10 +9,10 @@ use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder;
$targetNode = new UUID("0b368d41-7c15-42c8-899c-2b178ae9d983"); $targetNode = new UUID("0b368d41-7c15-42c8-899c-2b178ae9d983");
$result = QueryBuilder::Select() $result = QueryBuilder::Select()
->RelativePaths(["@id", "name"]) ->relativePaths(["@id", "name"])
->From($targetNode) ->from($targetNode)
->Build() ->build()
->RunQuery( ->runQuery(
actorID: DeegraphConnection::Actor(), actorID: DeegraphConnection::Actor(),
server: DeegraphConnection::DB(), server: DeegraphConnection::DB(),
) )

6
src/DataStructures/DataURL.php

@ -52,7 +52,7 @@ class DataURL
* *
* @return string|null The raw data or null if parsing failed. * @return string|null The raw data or null if parsing failed.
*/ */
public function GetData(): ?string public function getData(): ?string
{ {
return $this->Data; return $this->Data;
} }
@ -62,7 +62,7 @@ class DataURL
* *
* @return int The size of the data, or 0 if data is null. * @return int The size of the data, or 0 if data is null.
*/ */
public function GetSize(): int public function getSize(): int
{ {
return $this->Data ? strlen($this->Data) : 0; return $this->Data ? strlen($this->Data) : 0;
} }
@ -72,7 +72,7 @@ class DataURL
* *
* @return string|null The MIME type or null if parsing failed. * @return string|null The MIME type or null if parsing failed.
*/ */
public function GetMimeType(): ?string public function getMimeType(): ?string
{ {
return $this->MIMEType; return $this->MIMEType;
} }

2
src/DataStructures/DeegraphNodeDetails.php

@ -41,7 +41,7 @@ class DeegraphNodeDetails
} }
} }
public function AsJSON(): string public function asJSON(): string
{ {
$createdAt = null; $createdAt = null;
if (isset($this->CreatedAt)) if (isset($this->CreatedAt))

2
src/DataStructures/UUID.php

@ -26,7 +26,7 @@ class UUID
return "{" . $this->UUID . "}"; return "{" . $this->UUID . "}";
} }
public function GetPlainUUID(): string public function getPlainUUID(): string
{ {
return $this->UUID; return $this->UUID;
} }

4
src/QueryBuilder/DeleteQuery/DeleteQuery.php

@ -19,9 +19,9 @@ class DeleteQuery
return $this->QueryString; return $this->QueryString;
} }
public function RunQuery(UUID $actorID, DeegraphServer $server): DeleteQueryResponse public function runQuery(UUID $actorID, DeegraphServer $server): DeleteQueryResponse
{ {
$response = $server->RunQuery( $response = $server->runQuery(
actorID: $actorID, actorID: $actorID,
queryString: $this->QueryString, queryString: $this->QueryString,
); );

8
src/QueryBuilder/DeleteQuery/DeleteQueryBuilder.php

@ -17,16 +17,16 @@ class DeleteQueryBuilder
protected string $RelativePath = ""; protected string $RelativePath = "";
public function RelativePath(string $relativePath): DeleteQueryBuilder public function relativePath(string $relativePath): DeleteQueryBuilder
{ {
self::ValidateDeegraphPath(target: $relativePath); self::validateDeegraphPath(target: $relativePath);
$this->RelativePath = $relativePath; $this->RelativePath = $relativePath;
return $this; return $this;
} }
public function Build(): DeleteQuery public function build(): DeleteQuery
{ {
self::ValidateValues(target: $this); self::validateValues(target: $this);
$builder = "DELETE " . $this->RelativePath; $builder = "DELETE " . $this->RelativePath;

4
src/QueryBuilder/DirectoryQuery/DirectoryQuery.php

@ -18,9 +18,9 @@ final class DirectoryQuery
return $this->QueryString; return $this->QueryString;
} }
public function RunQuery(UUID $actorID, DeegraphServer $server): DirectoryQueryResponse public function runQuery(UUID $actorID, DeegraphServer $server): DirectoryQueryResponse
{ {
$response = $server->RunQuery( $response = $server->runQuery(
actorID: $actorID, actorID: $actorID,
queryString: $this->QueryString, queryString: $this->QueryString,
); );

8
src/QueryBuilder/DirectoryQuery/DirectoryQueryBuilder.php

@ -17,16 +17,16 @@ final class DirectoryQueryBuilder
protected string $RelativePath = ""; protected string $RelativePath = "";
public function RelativePath(string $relativePath): DirectoryQueryBuilder public function relativePath(string $relativePath): DirectoryQueryBuilder
{ {
self::ValidateDeegraphPath(target: $relativePath); self::validateDeegraphPath(target: $relativePath);
$this->RelativePath = $relativePath; $this->RelativePath = $relativePath;
return $this; return $this;
} }
public function Build(): DirectoryQuery public function build(): DirectoryQuery
{ {
self::ValidateValues(target: $this); self::validateValues(target: $this);
$builder = "DIRECTORY " . $this->RelativePath; $builder = "DIRECTORY " . $this->RelativePath;

16
src/QueryBuilder/InsertQuery/InsertQueryBuilder.php

@ -34,44 +34,44 @@ final class InsertQueryBuilder implements InsertQueryBuilderInterface
} }
public function RelativePath(string $relativePath): InsertQueryBuilder public function relativePath(string $relativePath): InsertQueryBuilder
{ {
self::ValidateDeegraphPath(target: $relativePath); self::validateDeegraphPath(target: $relativePath);
$this->RelativePath = $relativePath; $this->RelativePath = $relativePath;
return $this; return $this;
} }
public function Keys(string $keys): InsertQueryBuilder public function keys(string $keys): InsertQueryBuilder
{ {
$this->Keys = $keys; $this->Keys = $keys;
return $this; return $this;
} }
public function Schemas(string $schemas): InsertQueryBuilder public function schemas(string $schemas): InsertQueryBuilder
{ {
$this->Schemas = $schemas; $this->Schemas = $schemas;
return $this; return $this;
} }
public function Values(string $values): InsertQueryBuilder public function values(string $values): InsertQueryBuilder
{ {
$this->Values .= $values; $this->Values .= $values;
return $this; return $this;
} }
public function Duplicate(): InsertQueryBuilder public function duplicate(): InsertQueryBuilder
{ {
$this->Duplicate = true; $this->Duplicate = true;
return $this; return $this;
} }
public function Replace(): InsertQueryBuilder public function replace(): InsertQueryBuilder
{ {
$this->Replace = true; $this->Replace = true;
return $this; return $this;
} }
public function Build(): InsertQuery public function build(): InsertQuery
{ {
$instance = new QueryBuilderQuery(); $instance = new QueryBuilderQuery();
$instance->ValidateValues($this); $instance->ValidateValues($this);

2
src/QueryBuilder/InsertQuery/InsertQueryBuilderInterface.php

@ -4,5 +4,5 @@ namespace Darksparrow\DeegraphInteractions\QueryBuilder\InsertQuery;
interface InsertQueryBuilderInterface interface InsertQueryBuilderInterface
{ {
public function Build() : InsertQuery; public function build() : InsertQuery;
} }

4
src/QueryBuilder/LinkQuery/LinkQuery.php

@ -19,9 +19,9 @@ class LinkQuery
return $this->QueryString; return $this->QueryString;
} }
public function RunQuery(UUID $actorID, DeegraphServer $server): LinkQueryResponse public function runQuery(UUID $actorID, DeegraphServer $server): LinkQueryResponse
{ {
$response = $server->RunQuery( $response = $server->runQuery(
actorID: $actorID, actorID: $actorID,
queryString: $this->QueryString, queryString: $this->QueryString,
); );

38
src/QueryBuilder/LinkQuery/LinkQueryBuilder.php

@ -31,24 +31,24 @@ class LinkQueryBuilder
public function LinkToRelativePath(string $relativePath1, string $relativePath2): LinkQueryBuilder public function linkToRelativePath(string $relativePath1, string $relativePath2): LinkQueryBuilder
{ {
self::EnsureNotSet($this->RelativePath1); self::ensureNotSet($this->RelativePath1);
self::EnsureNotSet($this->RelativePath2); self::ensureNotSet($this->RelativePath2);
self::ValidateDeegraphPath(target: $relativePath1); self::validateDeegraphPath(target: $relativePath1);
self::ValidateDeegraphPath(target: $relativePath2); self::validateDeegraphPath(target: $relativePath2);
$this->RelativePath1 = $relativePath1; $this->RelativePath1 = $relativePath1;
$this->RelativePath2 = $relativePath2; $this->RelativePath2 = $relativePath2;
$this->ToOrOf = "TO"; $this->ToOrOf = "TO";
return $this; return $this;
} }
public function LinkOfRelativePath(string $relativePath1, string $relativePath2): LinkQueryBuilder public function linkOfRelativePath(string $relativePath1, string $relativePath2): LinkQueryBuilder
{ {
self::EnsureNotSet($this->RelativePath1); self::ensureNotSet($this->RelativePath1);
self::EnsureNotSet($this->RelativePath2); self::ensureNotSet($this->RelativePath2);
self::ValidateDeegraphPath(target: $relativePath1); self::validateDeegraphPath(target: $relativePath1);
self::ValidateDeegraphPath(target: $relativePath2); self::validateDeegraphPath(target: $relativePath2);
$this->RelativePath1 = $relativePath1; $this->RelativePath1 = $relativePath1;
$this->RelativePath2 = $relativePath2; $this->RelativePath2 = $relativePath2;
@ -58,7 +58,7 @@ class LinkQueryBuilder
public function As(string $propertyName): LinkQueryBuilder public function as(string $propertyName): LinkQueryBuilder
{ {
$this->PropertyName = $propertyName; $this->PropertyName = $propertyName;
return $this; return $this;
@ -66,30 +66,30 @@ class LinkQueryBuilder
public function Overwrite(): LinkQueryBuilder public function overwrite(): LinkQueryBuilder
{ {
self::EnsureNotSet($this->Mode); self::ensureNotSet($this->Mode);
$this->Mode = "OVERWRITE"; $this->Mode = "OVERWRITE";
return $this; return $this;
} }
public function Replace(): LinkQueryBuilder public function replace(): LinkQueryBuilder
{ {
self::EnsureNotSet($this->Mode); self::ensureNotSet($this->Mode);
$this->Mode = "REPLACE"; $this->Mode = "REPLACE";
return $this; return $this;
} }
public function Force(): LinkQueryBuilder public function force(): LinkQueryBuilder
{ {
self::EnsureNotSet($this->Mode); self::ensureNotSet($this->Mode);
$this->Mode = "FORCE"; $this->Mode = "FORCE";
return $this; return $this;
} }
public function Build(): LinkQuery public function build(): LinkQuery
{ {
self::ValidateValues(target: $this); self::validateValues(target: $this);
$builder = "LINK " $builder = "LINK "
. $this->RelativePath1 . $this->RelativePath1

4
src/QueryBuilder/PermissionsQuery/PermissionQuery.php

@ -18,9 +18,9 @@ final class PermissionQuery
return $this->QueryString; return $this->QueryString;
} }
public function RunQuery(UUID $actorID, DeegraphServer $server): PermissionQueryResponse public function runQuery(UUID $actorID, DeegraphServer $server): PermissionQueryResponse
{ {
$response = $server->RunQuery( $response = $server->runQuery(
actorID: $actorID, actorID: $actorID,
queryString: $this->QueryString, queryString: $this->QueryString,
); );

8
src/QueryBuilder/PermissionsQuery/PermissionQueryBuilder.php

@ -16,16 +16,16 @@ final class PermissionQueryBuilder
protected string $On = ""; protected string $On = "";
public function On(string $relativePath): PermissionQueryBuilder public function on(string $relativePath): PermissionQueryBuilder
{ {
self::ValidateDeegraphPath(target: $relativePath); self::validateDeegraphPath(target: $relativePath);
$this->On = $relativePath; $this->On = $relativePath;
return $this; return $this;
} }
public function Build(): PermissionQuery public function build(): PermissionQuery
{ {
self::ValidateValues(target: $this); self::validateValues(target: $this);
$builder = "PERMISSIONS ON ". $this->On; $builder = "PERMISSIONS ON ". $this->On;

2
src/QueryBuilder/PermissionsQuery/PermissionQueryBuilderInterface.php

@ -4,5 +4,5 @@ namespace Darksparrow\DeegraphInteractions\QueryBuilder\PermissionsQuery;
interface PermissionQueryBuilderInterface interface PermissionQueryBuilderInterface
{ {
public function Build() : PermissionQuery; public function build() : PermissionQuery;
} }

2
src/QueryBuilder/PermissionsQuery/PermissionQueryResponse.php

@ -35,7 +35,7 @@ final class PermissionQueryResponse
} }
} }
public function AsArray(): array public function asArray(): array
{ {
return $this->AsArray; return $this->AsArray;
} }

26
src/QueryBuilder/PutQuery/PutQueryBuilder.php

@ -41,9 +41,9 @@ final class PutQueryBuilder
/** /**
* @throws QueryBuilderInvalidInputException * @throws QueryBuilderInvalidInputException
*/ */
public function Schema(string $uri): PutQueryBuilder public function schema(string $uri): PutQueryBuilder
{ {
$this->PutWhat = self::RegexValidate( $this->PutWhat = self::regexValidate(
target: "SCHEMA \"$uri\"", target: "SCHEMA \"$uri\"",
pattern: "/SCHEMA \".+\"/" pattern: "/SCHEMA \".+\"/"
); );
@ -53,9 +53,9 @@ final class PutQueryBuilder
/** /**
* @throws QueryBuilderInvalidInputException * @throws QueryBuilderInvalidInputException
*/ */
public function URI(string $uri): PutQueryBuilder public function uri(string $uri): PutQueryBuilder
{ {
$this->PutWhat = self::RegexValidate( $this->PutWhat = self::regexValidate(
target: "URI \"$uri\"", target: "URI \"$uri\"",
pattern: "/URI \".+\"/" pattern: "/URI \".+\"/"
); );
@ -65,9 +65,9 @@ final class PutQueryBuilder
/** /**
* @throws QueryBuilderInvalidInputException * @throws QueryBuilderInvalidInputException
*/ */
public function DataURI(string $mimeType, string $data): PutQueryBuilder public function dataURI(string $mimeType, string $data): PutQueryBuilder
{ {
$this->PutWhat = self::RegexValidate( $this->PutWhat = self::regexValidate(
target: "URI \"data:$mimeType;$data\"", target: "URI \"data:$mimeType;$data\"",
pattern: "/URI \"data:[a-zA-Z0-9]/[a-zA-Z0-9];.+\"/" pattern: "/URI \"data:[a-zA-Z0-9]/[a-zA-Z0-9];.+\"/"
); );
@ -79,10 +79,10 @@ final class PutQueryBuilder
* @throws QueryBuilderInvalidInputException * @throws QueryBuilderInvalidInputException
* @throws QueryBuilderConflictingFieldAlreadyExistsException * @throws QueryBuilderConflictingFieldAlreadyExistsException
*/ */
public function At(string $node, string $uwu): PutQueryBuilder public function at(string $node, string $uwu): PutQueryBuilder
{ {
self::EnsureNotSet($this->PutInto); self::ensureNotSet($this->PutInto);
$this->PutAt = self::RegexValidate( $this->PutAt = self::regexValidate(
target: 'AT {' . $node . '}/' . $uwu, target: 'AT {' . $node . '}/' . $uwu,
pattern: "/AT {[a-zA-Z0-9\-]+}\/[a-zA-Z0-9]+/" pattern: "/AT {[a-zA-Z0-9\-]+}\/[a-zA-Z0-9]+/"
); );
@ -94,10 +94,10 @@ final class PutQueryBuilder
* @throws QueryBuilderInvalidInputException * @throws QueryBuilderInvalidInputException
* @throws QueryBuilderConflictingFieldAlreadyExistsException * @throws QueryBuilderConflictingFieldAlreadyExistsException
*/ */
public function Into(string $relativePath, string $propertyName): PutQueryBuilder public function into(string $relativePath, string $propertyName): PutQueryBuilder
{ {
self::EnsureNotSet($this->PutAt); self::ensureNotSet($this->PutAt);
$this->PutInto = self::RegexValidate( $this->PutInto = self::regexValidate(
target: "INTO \"$relativePath\" AS \"$propertyName\"", target: "INTO \"$relativePath\" AS \"$propertyName\"",
pattern: "/INTO \"[a-zA-Z0-9\-]+\" AS \"[a-zA-Z0-9]+\"/" pattern: "/INTO \"[a-zA-Z0-9\-]+\" AS \"[a-zA-Z0-9]+\"/"
); );
@ -105,7 +105,7 @@ final class PutQueryBuilder
} }
public function Safe(): PutQueryBuilder public function safe(): PutQueryBuilder
{ {
$this->Safe = true; $this->Safe = true;
return $this; return $this;

4
src/QueryBuilder/ReferencesQuery/ReferencesQuery.php

@ -18,9 +18,9 @@ final class ReferencesQuery
return $this->QueryString; return $this->QueryString;
} }
public function RunQuery(UUID $actorID, DeegraphServer $server): ReferencesQueryResponse public function runQuery(UUID $actorID, DeegraphServer $server): ReferencesQueryResponse
{ {
$response = $server->RunQuery( $response = $server->runQuery(
actorID: $actorID, actorID: $actorID,
queryString: $this->QueryString, queryString: $this->QueryString,
); );

8
src/QueryBuilder/ReferencesQuery/ReferencesQueryBuilder.php

@ -17,16 +17,16 @@ final class ReferencesQueryBuilder
protected string $RelativePath = ""; protected string $RelativePath = "";
public function RelativePath(string $relativePath): ReferencesQueryBuilder public function relativePath(string $relativePath): ReferencesQueryBuilder
{ {
self::ValidateDeegraphPath(target: $relativePath); self::validateDeegraphPath(target: $relativePath);
$this->RelativePath = $relativePath; $this->RelativePath = $relativePath;
return $this; return $this;
} }
public function Build(): ReferencesQuery public function build(): ReferencesQuery
{ {
self::ValidateValues(target: $this); self::validateValues(target: $this);
$builder = "REFERENCES " . $this->RelativePath; $builder = "REFERENCES " . $this->RelativePath;

4
src/QueryBuilder/SelectQuery/SelectQuery.php

@ -18,9 +18,9 @@ class SelectQuery
return $this->QueryString; return $this->QueryString;
} }
public function RunQuery(UUID $actorID, DeegraphServer $server): SelectQueryResponse public function runQuery(UUID $actorID, DeegraphServer $server): SelectQueryResponse
{ {
$response = $server->RunQuery( $response = $server->runQuery(
actorID: $actorID, actorID: $actorID,
queryString: $this->QueryString, queryString: $this->QueryString,
); );

12
src/QueryBuilder/SelectQuery/SelectQueryBuilder.php

@ -23,33 +23,33 @@ final class SelectQueryBuilder implements SelectQueryBuilderInterface
{ {
} }
public function AddRelativePath(string $relativePath): SelectQueryBuilder public function addRelativePath(string $relativePath): SelectQueryBuilder
{ {
$this->RelativePaths[] = $relativePath; $this->RelativePaths[] = $relativePath;
return $this; return $this;
} }
public function RelativePaths(array $relativePaths): SelectQueryBuilder public function relativePaths(array $relativePaths): SelectQueryBuilder
{ {
$this->RelativePaths = $relativePaths; $this->RelativePaths = $relativePaths;
return $this; return $this;
} }
public function From(string $target): SelectQueryBuilder public function from(string $target): SelectQueryBuilder
{ {
$this->From = "" . $target; $this->From = "" . $target;
return $this; return $this;
} }
public function Where(string $target, DeegraphEqualityOperator $operator, string $value): SelectQueryBuilder public function where(string $target, DeegraphEqualityOperator $operator, string $value): SelectQueryBuilder
{ {
$this->Where = "" . $target . " " . $operator->value . " " . $value; $this->Where = "" . $target . " " . $operator->value . " " . $value;
return $this; return $this;
} }
public function InstanceOf(string $schema): SelectQueryBuilder public function instanceOf(string $schema): SelectQueryBuilder
{ {
$this->InstanceOf = "" . $schema; $this->InstanceOf = "" . $schema;
return $this; return $this;
} }
public function Build(): SelectQuery public function build(): SelectQuery
{ {
$builder = "SELECT"; $builder = "SELECT";
if(sizeof($this->RelativePaths)) $builder .= " " . implode(separator: ", ", array: $this->RelativePaths); if(sizeof($this->RelativePaths)) $builder .= " " . implode(separator: ", ", array: $this->RelativePaths);

2
src/QueryBuilder/SelectQuery/SelectQueryBuilderInterface.php

@ -4,5 +4,5 @@ namespace Darksparrow\DeegraphInteractions\QueryBuilder\SelectQuery;
interface SelectQueryBuilderInterface interface SelectQueryBuilderInterface
{ {
public function Build() : SelectQuery; public function build() : SelectQuery;
} }

4
src/QueryBuilder/UnlinkQuery/UnlinkQuery.php

@ -19,9 +19,9 @@ class UnlinkQuery
return $this->QueryString; return $this->QueryString;
} }
public function RunQuery(UUID $actorID, DeegraphServer $server): UnlinkQueryResponse public function runQuery(UUID $actorID, DeegraphServer $server): UnlinkQueryResponse
{ {
$response = $server->RunQuery( $response = $server->runQuery(
actorID: $actorID, actorID: $actorID,
queryString: $this->QueryString, queryString: $this->QueryString,
); );

14
src/QueryBuilder/UnlinkQuery/UnlinkQueryBuilder.php

@ -23,21 +23,21 @@ class UnlinkQueryBuilder
protected string $RelativePath = ""; protected string $RelativePath = "";
public function UnlinkWhat(string $propertyName): UnlinkQueryBuilder public function unlinkWhat(string $propertyName): UnlinkQueryBuilder
{ {
$this->PropertyName = $propertyName; $this->PropertyName = $propertyName;
return $this; return $this;
} }
public function From(string $relativePath): UnlinkQueryBuilder public function from(string $relativePath): UnlinkQueryBuilder
{ {
self::EnsureNotSet($this->Mode); self::ensureNotSet($this->Mode);
$this->Mode = "FROM"; $this->Mode = "FROM";
$this->RelativePath = $relativePath; $this->RelativePath = $relativePath;
return $this; return $this;
} }
public function Of(string $relativePath): UnlinkQueryBuilder public function of(string $relativePath): UnlinkQueryBuilder
{ {
self::EnsureNotSet($this->Mode); self::ensureNotSet($this->Mode);
$this->Mode = "OF"; $this->Mode = "OF";
$this->RelativePath = $relativePath; $this->RelativePath = $relativePath;
return $this; return $this;
@ -46,9 +46,9 @@ class UnlinkQueryBuilder
public function Build(): UnlinkQuery public function build(): UnlinkQuery
{ {
self::ValidateValues(target: $this); self::validateValues(target: $this);
$builder = "UNLINK " $builder = "UNLINK "
. $this->PropertyName . $this->PropertyName

2
src/Utilities/RelativePath.php

@ -6,7 +6,7 @@ use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderInvalidInputExceptio
class RelativePath class RelativePath
{ {
public static function Validate(string $target): bool public static function validate(string $target): bool
{ {
if (!preg_match(pattern: "/(^(\{[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}\})$)|(^\{[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}\}(\/([a-z][a-z0-9]*|[0-9]+|#|\*))+$)|(^(([a-z][a-z0-9]*|[0-9]+|#|\*))(\/([a-z][a-z0-9]*|[0-9]+|#|\*))*$)/", subject: $target)) if (!preg_match(pattern: "/(^(\{[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}\})$)|(^\{[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}\}(\/([a-z][a-z0-9]*|[0-9]+|#|\*))+$)|(^(([a-z][a-z0-9]*|[0-9]+|#|\*))(\/([a-z][a-z0-9]*|[0-9]+|#|\*))*$)/", subject: $target))
return false; return false;

4
tests/QueryBuilderDeleteTest.php

@ -12,8 +12,8 @@ final class QueryBuilderDeleteTest extends TestCase
public function test0() public function test0()
{ {
$query = QueryBuilder::Delete() $query = QueryBuilder::Delete()
->RelativePath($this->TestUUID) ->relativePath($this->TestUUID)
->Build(); ->build();
self::assertEquals( self::assertEquals(
expected: "DELETE {$this->TestUUID}", expected: "DELETE {$this->TestUUID}",
actual: $query actual: $query

4
tests/QueryBuilderDirectoryTest.php

@ -10,8 +10,8 @@ final class QueryBuilderDirectoryTest extends TestCase
public function testReferenceQuery() public function testReferenceQuery()
{ {
$query = QueryBuilder::Directory() $query = QueryBuilder::Directory()
->RelativePath("{00000000-0000-0000-0000-000000000000}") ->relativePath("{00000000-0000-0000-0000-000000000000}")
->Build(); ->build();
self::assertEquals( self::assertEquals(
expected: 'DIRECTORY {00000000-0000-0000-0000-000000000000}', expected: 'DIRECTORY {00000000-0000-0000-0000-000000000000}',
actual: $query actual: $query

48
tests/QueryBuilderLinkTest.php

@ -14,9 +14,9 @@ final class QueryBuilderLinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test", expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test",
actual: QueryBuilder::Link() actual: QueryBuilder::Link()
->LinkToRelativePath($this->TestUUID, $this->TestUUID) ->linkToRelativePath($this->TestUUID, $this->TestUUID)
->As("test") ->as("test")
->Build() ->build()
); );
} }
public function test1() public function test1()
@ -24,10 +24,10 @@ final class QueryBuilderLinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test OVERWRITE", expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test OVERWRITE",
actual: QueryBuilder::Link() actual: QueryBuilder::Link()
->LinkToRelativePath($this->TestUUID, $this->TestUUID) ->linkToRelativePath($this->TestUUID, $this->TestUUID)
->As("test") ->as("test")
->Overwrite() ->overwrite()
->Build() ->build()
); );
} }
public function test2() public function test2()
@ -35,10 +35,10 @@ final class QueryBuilderLinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test REPLACE", expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test REPLACE",
actual: QueryBuilder::Link() actual: QueryBuilder::Link()
->LinkToRelativePath($this->TestUUID, $this->TestUUID) ->linkToRelativePath($this->TestUUID, $this->TestUUID)
->As("test") ->as("test")
->Replace() ->replace()
->Build() ->build()
); );
} }
public function test3() public function test3()
@ -46,10 +46,10 @@ final class QueryBuilderLinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test FORCE", expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test FORCE",
actual: QueryBuilder::Link() actual: QueryBuilder::Link()
->LinkToRelativePath($this->TestUUID, $this->TestUUID) ->linkToRelativePath($this->TestUUID, $this->TestUUID)
->As("test") ->as("test")
->Force() ->force()
->Build() ->build()
); );
} }
public function test4() public function test4()
@ -57,9 +57,9 @@ final class QueryBuilderLinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "LINK {$this->TestUUID} OF {$this->TestUUID} AS test", expected: "LINK {$this->TestUUID} OF {$this->TestUUID} AS test",
actual: QueryBuilder::Link() actual: QueryBuilder::Link()
->LinkOfRelativePath($this->TestUUID, $this->TestUUID) ->linkOfRelativePath($this->TestUUID, $this->TestUUID)
->As("test") ->as("test")
->Build() ->build()
); );
} }
public function test5() public function test5()
@ -68,12 +68,12 @@ final class QueryBuilderLinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "LINK {$this->TestUUID} OF {$this->TestUUID} AS test", expected: "LINK {$this->TestUUID} OF {$this->TestUUID} AS test",
actual: QueryBuilder::Link() actual: QueryBuilder::Link()
->LinkOfRelativePath($this->TestUUID, $this->TestUUID) ->linkOfRelativePath($this->TestUUID, $this->TestUUID)
->As("test") ->as("test")
->Overwrite() ->overwrite()
->Replace() ->replace()
->Force() ->force()
->Build() ->build()
); );
} }
} }

4
tests/QueryBuilderPermissionsTest.php

@ -10,8 +10,8 @@ final class QueryBuilderPermissionsTest extends TestCase
public function testReferenceQuery() public function testReferenceQuery()
{ {
$query = QueryBuilder::Permission() $query = QueryBuilder::Permission()
->On("{00000000-0000-0000-0000-000000000000}") ->on("{00000000-0000-0000-0000-000000000000}")
->Build(); ->build();
self::assertEquals( self::assertEquals(
expected: 'PERMISSIONS ON {00000000-0000-0000-0000-000000000000}', expected: 'PERMISSIONS ON {00000000-0000-0000-0000-000000000000}',
actual: $query actual: $query

14
tests/QueryBuilderPutTest.php

@ -11,9 +11,9 @@ final class QueryBuilderPutTest extends TestCase
{ {
$queryBuilder = new QueryBuilder(); $queryBuilder = new QueryBuilder();
$query = $queryBuilder->Put() $query = $queryBuilder->Put()
->URI("https://schemas.auxiliumsoftware.co.uk/v1/collection.json") ->uri("https://schemas.auxiliumsoftware.co.uk/v1/collection.json")
->At(node: "970334ed-1f4f-465a-94d7-923a99698786", uwu: "todos") ->at(node: "970334ed-1f4f-465a-94d7-923a99698786", uwu: "todos")
->Safe(); ->safe();
self::assertEquals( self::assertEquals(
expected: 'PUT URI "https://schemas.auxiliumsoftware.co.uk/v1/collection.json" AT {970334ed-1f4f-465a-94d7-923a99698786}/todos SAFE', expected: 'PUT URI "https://schemas.auxiliumsoftware.co.uk/v1/collection.json" AT {970334ed-1f4f-465a-94d7-923a99698786}/todos SAFE',
actual: $query actual: $query
@ -24,9 +24,9 @@ final class QueryBuilderPutTest extends TestCase
$this->expectException(QueryBuilderConflictingFieldAlreadyExistsException::class); $this->expectException(QueryBuilderConflictingFieldAlreadyExistsException::class);
$queryBuilder = new QueryBuilder(); $queryBuilder = new QueryBuilder();
$query = $queryBuilder->Put() $query = $queryBuilder->Put()
->URI("https://schemas.auxiliumsoftware.co.uk/v1/collection.json") ->uri("https://schemas.auxiliumsoftware.co.uk/v1/collection.json")
->At(node: "970334ed-1f4f-465a-94d7-923a99698786", uwu: "todos") ->at(node: "970334ed-1f4f-465a-94d7-923a99698786", uwu: "todos")
->Into(relativePath: "Relative Path", propertyName: "OwO") ->into(relativePath: "Relative Path", propertyName: "OwO")
->Safe(); ->safe();
} }
} }

4
tests/QueryBuilderReferencesTest.php

@ -10,8 +10,8 @@ final class QueryBuilderReferencesTest extends TestCase
public function testReferenceQuery() public function testReferenceQuery()
{ {
$query = QueryBuilder::References() $query = QueryBuilder::References()
->RelativePath("{00000000-0000-0000-0000-000000000000}") ->relativePath("{00000000-0000-0000-0000-000000000000}")
->Build(); ->build();
self::assertEquals( self::assertEquals(
expected: 'REFERENCES {00000000-0000-0000-0000-000000000000}', expected: 'REFERENCES {00000000-0000-0000-0000-000000000000}',
actual: $query actual: $query

12
tests/QueryBuilderSelectTest.php

@ -16,9 +16,9 @@ final class QueryBuilderSelectTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "SELECT @path FROM ./cases/#", expected: "SELECT @path FROM ./cases/#",
actual: QueryBuilder::Select() actual: QueryBuilder::Select()
->RelativePaths(["@path"]) ->relativePaths(["@path"])
->From("./cases/#") ->from("./cases/#")
->Build() ->build()
); );
} }
public function test1() public function test1()
@ -26,9 +26,9 @@ final class QueryBuilderSelectTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "SELECT clients/0/name FROM {0b368d41-7c15-42c8-899c-2b178ae9d983}/cases/0", expected: "SELECT clients/0/name FROM {0b368d41-7c15-42c8-899c-2b178ae9d983}/cases/0",
actual: QueryBuilder::Select() actual: QueryBuilder::Select()
->AddRelativePath("clients/0/name") ->addRelativePath("clients/0/name")
->From("{0b368d41-7c15-42c8-899c-2b178ae9d983}/cases/0") ->from("{0b368d41-7c15-42c8-899c-2b178ae9d983}/cases/0")
->Build() ->build()
); );
} }
} }

20
tests/QueryBuilderUnlinkTest.php

@ -16,9 +16,9 @@ final class QueryBuilderUnlinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "UNLINK test FROM {$this->TestUUID}", expected: "UNLINK test FROM {$this->TestUUID}",
actual: QueryBuilder::Unlink() actual: QueryBuilder::Unlink()
->UnlinkWhat("test") ->unlinkWhat("test")
->From($this->TestUUID) ->from($this->TestUUID)
->Build() ->build()
); );
} }
public function test1() public function test1()
@ -26,9 +26,9 @@ final class QueryBuilderUnlinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "UNLINK test OF {$this->TestUUID}", expected: "UNLINK test OF {$this->TestUUID}",
actual: QueryBuilder::Unlink() actual: QueryBuilder::Unlink()
->UnlinkWhat("test") ->unlinkWhat("test")
->Of($this->TestUUID) ->of($this->TestUUID)
->Build() ->build()
); );
} }
public function test2() public function test2()
@ -37,10 +37,10 @@ final class QueryBuilderUnlinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "UNLINK test FROM {$this->TestUUID}", expected: "UNLINK test FROM {$this->TestUUID}",
actual: QueryBuilder::Unlink() actual: QueryBuilder::Unlink()
->UnlinkWhat("test") ->unlinkWhat("test")
->From($this->TestUUID) ->from($this->TestUUID)
->Of($this->TestUUID) ->of($this->TestUUID)
->Build() ->build()
); );
} }
} }

6
tests/ValidateDeegraphPathTest.php

@ -11,14 +11,14 @@ final class ValidateDeegraphPathTest extends TestCase
{ {
public function testValidUUID() public function testValidUUID()
{ {
self::assertTrue(RelativePath::Validate("{00000000-0000-0000-0000-000000000000}")); self::assertTrue(RelativePath::validate("{00000000-0000-0000-0000-000000000000}"));
} }
public function testHash() public function testHash()
{ {
self::assertTrue(RelativePath::Validate("#")); self::assertTrue(RelativePath::validate("#"));
} }
public function testNumber() public function testNumber()
{ {
self::assertTrue(RelativePath::Validate("123")); self::assertTrue(RelativePath::validate("123"));
} }
} }

Loading…
Cancel
Save