Browse Source

nah too much work, cba lol

dev
Cerys 4 weeks ago
parent
commit
3b31c5c5ea
  1. 20
      src/QueryBuilder/LinkQuery/Building/LinkQuery_Step1.php
  2. 31
      src/QueryBuilder/LinkQuery/Building/LinkQuery_Step2.php
  3. 31
      src/QueryBuilder/LinkQuery/Building/LinkQuery_Step3.php
  4. 40
      src/QueryBuilder/LinkQuery/Building/LinkQuery_Step4.php
  5. 25
      src/QueryBuilder/LinkQuery/Building/LinkQuery_Step9.php
  6. 106
      src/QueryBuilder/LinkQuery/LinkQueryBuilder.php
  7. 5
      src/QueryBuilder/QueryBuilder.php
  8. 42
      tests/QueryBuilderLinkTest.php

20
src/QueryBuilder/LinkQuery/Building/LinkQuery_Step1.php

@ -1,20 +0,0 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\Building;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField;
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait;
#[QueryBuilderQuery]
class LinkQuery_Step1
{
use QueryBuilderTrait;
public function RelativePath(string $relativePath): LinkQuery_Step2
{
self::ValidateDeegraphPath(target: $relativePath);
return new LinkQuery_Step2(querySoFar: "LINK " . $relativePath);
}
}

31
src/QueryBuilder/LinkQuery/Building/LinkQuery_Step2.php

@ -1,31 +0,0 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\Building;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField;
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait;
#[QueryBuilderQuery]
class LinkQuery_Step2
{
use QueryBuilderTrait;
private string $QuerySoFar = "";
public function __construct(string $querySoFar)
{
$this->QuerySoFar = $querySoFar;
}
public function To(string $relativePath): LinkQuery_Step3
{
self::ValidateDeegraphPath(target: $relativePath);
return new LinkQuery_Step3($this->QuerySoFar . " TO " . $relativePath);
}
public function Of(string $relativePath): LinkQuery_Step3
{
self::ValidateDeegraphPath(target: $relativePath);
return new LinkQuery_Step3($this->QuerySoFar . " OF " . $relativePath);
}
}

31
src/QueryBuilder/LinkQuery/Building/LinkQuery_Step3.php

@ -1,31 +0,0 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\Building;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField;
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait;
#[QueryBuilderQuery]
class LinkQuery_Step3
{
use QueryBuilderTrait;
private string $QuerySoFar = "";
public function __construct(string $querySoFar)
{
$this->QuerySoFar = $querySoFar;
}
public function As(string $asPropertyName): LinkQuery_Step4
{
self::ValidateDeegraphPath(target: $asPropertyName);
return new LinkQuery_Step4($this->QuerySoFar . " AS " . $asPropertyName);
}
public function Build(): LinkQuery
{
return new LinkQuery($this->QuerySoFar);
}
}

40
src/QueryBuilder/LinkQuery/Building/LinkQuery_Step4.php

@ -1,40 +0,0 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\Building;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField;
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait;
#[QueryBuilderQuery]
class LinkQuery_Step4
{
use QueryBuilderTrait;
private string $QuerySoFar = "";
public function __construct(string $querySoFar)
{
$this->QuerySoFar = $querySoFar;
}
public function Overwrite(): LinkQuery_Step9
{
return new LinkQuery_Step9($this->QuerySoFar . " OVERWRITE");
}
public function Replace(): LinkQuery_Step9
{
return new LinkQuery_Step9($this->QuerySoFar . " REPLACE");
}
public function Force(): LinkQuery_Step9
{
return new LinkQuery_Step9($this->QuerySoFar . " FORCE");
}
public function Build(): LinkQuery
{
return new LinkQuery($this->QuerySoFar);
}
}

25
src/QueryBuilder/LinkQuery/Building/LinkQuery_Step9.php

@ -1,25 +0,0 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\Building;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField;
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait;
#[QueryBuilderQuery]
class LinkQuery_Step9
{
use QueryBuilderTrait;
private string $QuerySoFar = "";
public function __construct(string $querySoFar)
{
$this->QuerySoFar = $querySoFar;
}
public function Build()
{
return new LinkQuery($this->QuerySoFar);
}
}

106
src/QueryBuilder/LinkQuery/LinkQueryBuilder.php

@ -0,0 +1,106 @@
<?php
namespace Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery;
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField;
use Darksparrow\DeegraphInteractions\QueryBuilder\DirectoryQuery\DirectoryQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\DirectoryQuery\DirectoryQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait;
#[QueryBuilderQuery]
class LinkQueryBuilder
{
use QueryBuilderTrait;
#[QueryBuilderRequiredField]
protected string $RelativePath1 = "";
#[QueryBuilderRequiredField]
protected string $ToOrOf = "";
#[QueryBuilderRequiredField]
protected string $RelativePath2 = "";
#[QueryBuilderRequiredField]
protected string $PropertyName = "";
protected string $Mode = "";
public function LinkWhat(string $relativePath): LinkQueryBuilder
{
self::ValidateDeegraphPath(target: $relativePath);
$this->RelativePath1 = $relativePath;
return $this;
}
public function LinkTo(string $relativePath): LinkQueryBuilder
{
self::EnsureNotSet($this->RelativePath2);
self::ValidateDeegraphPath(target: $relativePath);
$this->RelativePath2 = $relativePath;
$this->ToOrOf = "TO";
return $this;
}
public function LinkOf(string $relativePath): LinkQueryBuilder
{
self::EnsureNotSet($this->RelativePath2);
self::ValidateDeegraphPath(target: $relativePath);
$this->RelativePath2 = $relativePath;
$this->ToOrOf = "OF";
return $this;
}
public function PropertyName(string $propertyName): LinkQueryBuilder
{
$this->PropertyName = $propertyName;
return $this;
}
public function Overwrite(): LinkQueryBuilder
{
self::EnsureNotSet($this->Mode);
$this->Mode = "OVERWRITE";
return $this;
}
public function Replace(): LinkQueryBuilder
{
self::EnsureNotSet($this->Mode);
$this->Mode = "REPLACE";
return $this;
}
public function Force(): LinkQueryBuilder
{
self::EnsureNotSet($this->Mode);
$this->Mode = "FORCE";
return $this;
}
public function Build(): LinkQuery
{
self::ValidateValues(target: $this);
$builder = "LINK "
. $this->RelativePath1
. " "
. $this->ToOrOf
. " "
. $this->RelativePath2
. " AS "
. $this->PropertyName;
if($this->Mode != "") $builder .= " " . $this->Mode;
return new LinkQuery(queryString: $builder);
}
}

5
src/QueryBuilder/QueryBuilder.php

@ -5,7 +5,6 @@ namespace Darksparrow\DeegraphInteractions\QueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\DeleteQuery\DeleteQueryBuilder; use Darksparrow\DeegraphInteractions\QueryBuilder\DeleteQuery\DeleteQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\DirectoryQuery\DirectoryQueryBuilder; use Darksparrow\DeegraphInteractions\QueryBuilder\DirectoryQuery\DirectoryQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\InsertQuery\InsertQuery; use Darksparrow\DeegraphInteractions\QueryBuilder\InsertQuery\InsertQuery;
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\Building\LinkQuery_Step1;
use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQueryBuilder; use Darksparrow\DeegraphInteractions\QueryBuilder\LinkQuery\LinkQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\PermissionsQuery\PermissionQueryBuilder; use Darksparrow\DeegraphInteractions\QueryBuilder\PermissionsQuery\PermissionQueryBuilder;
use Darksparrow\DeegraphInteractions\QueryBuilder\PutQuery\PutQueryBuilder; use Darksparrow\DeegraphInteractions\QueryBuilder\PutQuery\PutQueryBuilder;
@ -39,9 +38,9 @@ final class QueryBuilder
{ {
return new ReferencesQueryBuilder(); return new ReferencesQueryBuilder();
} }
public static function Link(): LinkQuery_Step1 public static function Link(): LinkQueryBuilder
{ {
return new LinkQuery_Step1(); return new LinkQueryBuilder();
} }
public static function Unlink(): UnlinkQueryBuilder public static function Unlink(): UnlinkQueryBuilder
{ {

42
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()
->RelativePath($this->TestUUID) ->LinkWhat($this->TestUUID)
->To($this->TestUUID) ->LinkTo($this->TestUUID)
->As("test") ->PropertyName("test")
->Build() ->Build()
); );
} }
@ -25,9 +25,9 @@ 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()
->RelativePath($this->TestUUID) ->LinkWhat($this->TestUUID)
->To($this->TestUUID) ->LinkTo($this->TestUUID)
->As("test") ->PropertyName("test")
->Overwrite() ->Overwrite()
->Build() ->Build()
); );
@ -37,9 +37,9 @@ 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()
->RelativePath($this->TestUUID) ->LinkWhat($this->TestUUID)
->To($this->TestUUID) ->LinkTo($this->TestUUID)
->As("test") ->PropertyName("test")
->Replace() ->Replace()
->Build() ->Build()
); );
@ -49,9 +49,9 @@ 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()
->RelativePath($this->TestUUID) ->LinkWhat($this->TestUUID)
->To($this->TestUUID) ->LinkTo($this->TestUUID)
->As("test") ->PropertyName("test")
->Force() ->Force()
->Build() ->Build()
); );
@ -61,23 +61,25 @@ 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()
->RelativePath($this->TestUUID) ->LinkWhat($this->TestUUID)
->Of($this->TestUUID) ->LinkOf($this->TestUUID)
->As("test") ->PropertyName("test")
->Build() ->Build()
); );
} }
/*
public function test5() public function test5()
{ {
self::expectException(QueryBuilderConflictingFieldAlreadyExistsException::class); self::expectException(QueryBuilderConflictingFieldAlreadyExistsException::class);
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()
->RelativePath($this->TestUUID) ->LinkWhat($this->TestUUID)
->Of($this->TestUUID) ->LinkOf($this->TestUUID)
->As("test") ->PropertyName("test")
->Overwrite()
->Replace()
->Force()
->Build()
); );
} }
*/
} }

Loading…
Cancel
Save