Skip to content

Commit

Permalink
refactor query builder (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
norbybaru authored Jul 8, 2022
1 parent 81ae228 commit 3136fad
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
20 changes: 0 additions & 20 deletions src/Builder/QueryBuilder.php

This file was deleted.

24 changes: 24 additions & 0 deletions src/Builder/TimestreamQueryBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace NorbyBaru\AwsTimestream\Builder;

final class TimestreamQueryBuilder extends Builder
{
public function __construct()
{
$this->builder();
}

/**
* Build SQL query
*
* @return void
*/
protected function builder(): void
{}

public static function query(): self
{
return new self();
}
}
4 changes: 2 additions & 2 deletions src/TimestreamBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Support\Carbon;
use NorbyBaru\AwsTimestream\Builder\PayloadBuilder;
use NorbyBaru\AwsTimestream\Builder\QueryBuilder;
use NorbyBaru\AwsTimestream\Builder\TimestreamQueryBuilder;
use NorbyBaru\AwsTimestream\Contract\PayloadBuilderContract;
use NorbyBaru\AwsTimestream\Contract\QueryBuilderContract;

Expand Down Expand Up @@ -42,6 +42,6 @@ public static function commonAttributes(array $attributes): array

public static function query(): QueryBuilderContract
{
return QueryBuilder::query();
return TimestreamQueryBuilder::query();
}
}
4 changes: 2 additions & 2 deletions src/TimestreamServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Support\ServiceProvider;
use NorbyBaru\AwsTimestream\Builder\PayloadBuilder;
use NorbyBaru\AwsTimestream\Builder\QueryBuilder;
use NorbyBaru\AwsTimestream\Builder\TimestreamQueryBuilder;
use NorbyBaru\AwsTimestream\Contract\PayloadBuilderContract;
use NorbyBaru\AwsTimestream\Contract\QueryBuilderContract;

Expand All @@ -19,7 +19,7 @@ public function register()
{
$this->mergeConfigFrom($this->configPath(), 'timestream');

$this->app->bind(QueryBuilderContract::class, QueryBuilder::class);
$this->app->bind(QueryBuilderContract::class, TimestreamQueryBuilder::class);
$this->app->bind(PayloadBuilderContract::class, PayloadBuilder::class);

$this->app->singleton(TimestreamManager::class, function ($app) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/QueryBuilderUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace NorbyBaru\AwsTimestream\Tests\Unit;

use NorbyBaru\AwsTimestream\Builder\QueryBuilder;
use NorbyBaru\AwsTimestream\Builder\TimestreamQueryBuilder;
use NorbyBaru\AwsTimestream\Contract\QueryBuilderContract;
use NorbyBaru\AwsTimestream\Tests\TestCase;
use NorbyBaru\AwsTimestream\TimestreamBuilder;
Expand Down Expand Up @@ -74,7 +74,7 @@ public function test_it_can_build_where_in_query()
$this->validateSql("WHERE state IN ('open','draft','published')", $query);
}

private function validateSql(string $expected, QueryBuilder $builder)
private function validateSql(string $expected, TimestreamQueryBuilder $builder)
{
$this->assertEquals($expected, trim($builder->getSql()));
}
Expand Down

0 comments on commit 3136fad

Please sign in to comment.