Browse Source

renamed the QueryBuilder Operation classes

they now end in "Query"
pull/1/head
Cerys Lewis 7 months ago
parent
commit
fd0fa7e224
  1. 8
      src/Attributes/QueryBuilderQuery.php
  2. 18
      src/QueryBuilder/QueryBuilder.php
  3. 14
      src/QueryBuilder/QueryBuilders/InsertQuery.php
  4. 15
      src/QueryBuilder/QueryBuilders/PutQuery.php
  5. 6
      src/QueryBuilder/QueryBuilders/SelectQuery.php

8
src/Attributes/QueryBuilderQuery.php

@ -2,9 +2,9 @@
namespace Darksparrow\DeegraphPHP\Attributes;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders\Insert;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders\Put;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders\Select;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders\InsertQuery;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders\PutQuery;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders\SelectQuery;
use PhpParser\Node\Attribute;
use PhpParser\Node\Name;
use ReflectionClass;
@ -17,7 +17,7 @@ use ReflectionClass;
}
public function ValidateValues(
Insert|Put|Select $target
InsertQuery|PutQuery|SelectQuery $target
): void
{
$nameBase = "Darksparrow\\DeegraphPHP\\Attributes";

18
src/QueryBuilder/QueryBuilder.php

@ -2,23 +2,23 @@
namespace Darksparrow\DeegraphPHP\QueryBuilder;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders\Insert;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders\Put;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders\Select;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders\InsertQuery;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders\PutQuery;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders\SelectQuery;
class QueryBuilder
{
public function Insert(): Insert
public function Insert(): InsertQuery
{
return new Insert();
return new InsertQuery();
}
public function Put(): Put
public function Put(): PutQuery
{
return new Put();
return new PutQuery();
}
public function Select(): Select
public function Select(): SelectQuery
{
return new Select();
return new SelectQuery();
}
}

14
src/QueryBuilder/QueryBuilders/Insert.php → src/QueryBuilder/QueryBuilders/InsertQuery.php

@ -7,7 +7,7 @@ use Darksparrow\DeegraphPHP\Attributes\QueryBuilderQuery;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilderTrait;
#[QueryBuilderQuery]
final class Insert
final class InsertQuery
{
use QueryBuilderTrait;
@ -45,37 +45,37 @@ final class Insert
return $builder;
}
public function RelativePath(string $relativePath): Insert
public function RelativePath(string $relativePath): InsertQuery
{
$this->RelativePath = $relativePath;
return $this;
}
public function Keys(string $keys): Insert
public function Keys(string $keys): InsertQuery
{
$this->Keys = $keys;
return $this;
}
public function Schemas(string $schemas): Insert
public function Schemas(string $schemas): InsertQuery
{
$this->Schemas = $schemas;
return $this;
}
public function Values(string $values): Insert
public function Values(string $values): InsertQuery
{
$this->Values .= $values;
return $this;
}
public function Duplicate(): Insert
public function Duplicate(): InsertQuery
{
$this->Duplicate = true;
return $this;
}
public function Replace(): Insert
public function Replace(): InsertQuery
{
$this->Replace = true;
return $this;

15
src/QueryBuilder/QueryBuilders/Put.php → src/QueryBuilder/QueryBuilders/PutQuery.php

@ -2,12 +2,13 @@
namespace Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilders;
use Darksparrow\DeegraphPHP\Attributes\QueryBuilderRequiredField;
use Darksparrow\DeegraphPHP\Exceptions\QueryBuilderConflictingFieldAlreadyExistsException;
use Darksparrow\DeegraphPHP\Exceptions\QueryBuilderInvalidInputException;
use Darksparrow\DeegraphPHP\Exceptions\QueryBuilderRequiredFieldIsNotSetException;
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilderTrait;
final class Put
final class PutQuery
{
use QueryBuilderTrait;
@ -41,7 +42,7 @@ final class Put
/**
* @throws QueryBuilderInvalidInputException
*/
public function Schema(string $uri): Put
public function Schema(string $uri): PutQuery
{
$this->PutWhat = self::Validate(
target: "SCHEMA \"$uri\"",
@ -53,7 +54,7 @@ final class Put
/**
* @throws QueryBuilderInvalidInputException
*/
public function URI(string $uri): Put
public function URI(string $uri): PutQuery
{
$this->PutWhat = self::Validate(
target: "URI \"$uri\"",
@ -65,7 +66,7 @@ final class Put
/**
* @throws QueryBuilderInvalidInputException
*/
public function DataURI(string $mimeType, string $data): Put
public function DataURI(string $mimeType, string $data): PutQuery
{
$this->PutWhat = self::Validate(
target: "URI \"data:$mimeType;$data\"",
@ -79,7 +80,7 @@ final class Put
* @throws QueryBuilderInvalidInputException
* @throws QueryBuilderConflictingFieldAlreadyExistsException
*/
public function At(string $node, string $uwu): Put
public function At(string $node, string $uwu): PutQuery
{
self::EnsureNotSet($this->PutInto);
$this->PutAt = self::Validate(
@ -94,7 +95,7 @@ final class Put
* @throws QueryBuilderInvalidInputException
* @throws QueryBuilderConflictingFieldAlreadyExistsException
*/
public function Into(string $relativePath, string $propertyName): Put
public function Into(string $relativePath, string $propertyName): PutQuery
{
self::EnsureNotSet($this->PutAt);
$this->PutInto = self::Validate(
@ -105,7 +106,7 @@ final class Put
}
public function Safe(): Put
public function Safe(): PutQuery
{
$this->Safe = true;
return $this;

6
src/QueryBuilder/QueryBuilders/Select.php → src/QueryBuilder/QueryBuilders/SelectQuery.php

@ -9,7 +9,7 @@ use Darksparrow\DeegraphPHP\Exceptions\QueryBuilderRequiredFieldIsNotSetExceptio
use Darksparrow\DeegraphPHP\QueryBuilder\QueryBuilderTrait;
#[QueryBuilderQuery]
final class Select
final class SelectQuery
{
use QueryBuilderTrait;
@ -38,12 +38,12 @@ final class Select
return $builder;
}
public function RelativePaths(array $relativePaths): Select
public function RelativePaths(array $relativePaths): SelectQuery
{
$this->RelativePaths = $relativePaths;
return $this;
}
public function Where(string $target, DeegraphEqualityOperator $operator, string $value): Select
public function Where(string $target, DeegraphEqualityOperator $operator, string $value): SelectQuery
{
$this->Where = "" . $target . " " . $operator->value . " " . $value;
return $this;
Loading…
Cancel
Save