Skip to content

Commit b9b6311

Browse files
committed
Add Transformation namespace
1 parent 5a5fa52 commit b9b6311

File tree

17 files changed

+102
-75
lines changed

17 files changed

+102
-75
lines changed

src/Query/Aggregation/AbstractAggregation.php

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,17 @@
33

44
namespace TBolier\RethinkQL\Query\Aggregation;
55

6-
use TBolier\RethinkQL\Query\AbstractQuery;
76
use TBolier\RethinkQL\Query\QueryInterface;
7+
use TBolier\RethinkQL\Query\Transformation\AbstractTransformation;
88

9-
abstract class AbstractAggregation extends AbstractQuery implements AggregationInterface
9+
abstract class AbstractAggregation extends AbstractTransformation implements AggregationInterface
1010
{
1111
/**
1212
* @inheritdoc
1313
*/
14-
public function isEmpty(): QueryInterface
14+
public function count(): QueryInterface
1515
{
16-
return new IsEmpty($this->rethink, $this->message, $this);
17-
}
18-
19-
/**
20-
* @inheritdoc
21-
*/
22-
public function limit($value): AggregationInterface
23-
{
24-
return new Limit($this->rethink, $this->message, $this, $value);
25-
}
26-
27-
/**
28-
* @inheritdoc
29-
*/
30-
public function skip($value): AggregationInterface
31-
{
32-
return new Skip($this->rethink, $this->message, $this, $value);
33-
}
34-
35-
/**
36-
* @inheritdoc
37-
*/
38-
public function orderBy($key): AggregationInterface
39-
{
40-
return new OrderBy($this->rethink, $this->message, $this, $key);
16+
return new Count($this->rethink, $this->message, $this);
4117
}
4218

4319
/**

src/Query/Aggregation/AggregationInterface.php

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,15 @@
44
namespace TBolier\RethinkQL\Query\Aggregation;
55

66
use TBolier\RethinkQL\Query\QueryInterface;
7+
use TBolier\RethinkQL\Query\Transformation\TransformationInterface;
78
use TBolier\RethinkQL\Response\ResponseInterface;
89

9-
interface AggregationInterface
10+
interface AggregationInterface extends TransformationInterface
1011
{
1112
/**
1213
* @return QueryInterface
1314
*/
14-
public function isEmpty(): QueryInterface;
15-
16-
/**
17-
* @param int $n
18-
* @return AggregationInterface
19-
*/
20-
public function limit($n): AggregationInterface;
21-
22-
/**
23-
* @param int $n
24-
* @return AggregationInterface
25-
*/
26-
public function skip($n): AggregationInterface;
27-
28-
/**
29-
* @param mixed|QueryInterface $key
30-
* @return AggregationInterface
31-
*/
32-
public function orderBy($key): AggregationInterface;
15+
public function count(): QueryInterface;
3316

3417
/**
3518
* @param string $key
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
declare(strict_types = 1);
33

4-
namespace TBolier\RethinkQL\Query\Operation;
4+
namespace TBolier\RethinkQL\Query\Aggregation;
55

66
use TBolier\RethinkQL\Message\MessageInterface;
77
use TBolier\RethinkQL\Query\AbstractQuery;

src/Query/Operation/AbstractOperation.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88

99
abstract class AbstractOperation extends AbstractAggregation implements OperationInterface
1010
{
11-
/**
12-
* @inheritdoc
13-
*/
14-
public function count(): QueryInterface
15-
{
16-
return new Count($this->rethink, $this->message, $this);
17-
}
18-
1911
/**
2012
* @inheritdoc
2113
*/

src/Query/Operation/OperationInterface.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99

1010
interface OperationInterface extends AggregationInterface
1111
{
12-
/**
13-
* @return QueryInterface
14-
*/
15-
public function count(): QueryInterface;
16-
1712
/**
1813
* @return QueryInterface
1914
*/
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
declare(strict_types = 1);
3+
4+
namespace TBolier\RethinkQL\Query\Transformation;
5+
6+
use TBolier\RethinkQL\Query\AbstractQuery;
7+
use TBolier\RethinkQL\Query\QueryInterface;
8+
9+
abstract class AbstractTransformation extends AbstractQuery implements TransformationInterface
10+
{
11+
/**
12+
* @inheritdoc
13+
*/
14+
public function isEmpty(): QueryInterface
15+
{
16+
return new IsEmpty($this->rethink, $this->message, $this);
17+
}
18+
19+
/**
20+
* @inheritdoc
21+
*/
22+
public function limit($value): TransformationInterface
23+
{
24+
return new Limit($this->rethink, $this->message, $this, $value);
25+
}
26+
27+
/**
28+
* @inheritdoc
29+
*/
30+
public function skip($value): TransformationInterface
31+
{
32+
return new Skip($this->rethink, $this->message, $this, $value);
33+
}
34+
35+
/**
36+
* @inheritdoc
37+
*/
38+
public function orderBy($key): TransformationInterface
39+
{
40+
return new OrderBy($this->rethink, $this->message, $this, $key);
41+
}
42+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
declare(strict_types = 1);
33

4-
namespace TBolier\RethinkQL\Query\Aggregation;
4+
namespace TBolier\RethinkQL\Query\Transformation;
55

66
use TBolier\RethinkQL\Message\MessageInterface;
77
use TBolier\RethinkQL\Query\AbstractQuery;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22
declare(strict_types = 1);
33

4-
namespace TBolier\RethinkQL\Query\Aggregation;
4+
namespace TBolier\RethinkQL\Query\Transformation;
55

66
use TBolier\RethinkQL\Message\MessageInterface;
77
use TBolier\RethinkQL\Query\QueryInterface;
88
use TBolier\RethinkQL\RethinkInterface;
99
use TBolier\RethinkQL\Types\Term\TermType;
1010

11-
class Limit extends AbstractAggregation
11+
class Limit extends AbstractTransformation
1212
{
1313
/**
1414
* @var int
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22
declare(strict_types = 1);
33

4-
namespace TBolier\RethinkQL\Query\Aggregation;
4+
namespace TBolier\RethinkQL\Query\Transformation;
55

66
use TBolier\RethinkQL\Message\MessageInterface;
77
use TBolier\RethinkQL\Query\QueryInterface;
88
use TBolier\RethinkQL\RethinkInterface;
99
use TBolier\RethinkQL\Types\Term\TermType;
1010

11-
class OrderBy extends AbstractAggregation
11+
class OrderBy extends AbstractTransformation
1212
{
1313
/**
1414
* @var mixed|QueryInterface
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22
declare(strict_types = 1);
33

4-
namespace TBolier\RethinkQL\Query\Aggregation;
4+
namespace TBolier\RethinkQL\Query\Transformation;
55

66
use TBolier\RethinkQL\Message\MessageInterface;
77
use TBolier\RethinkQL\Query\QueryInterface;
88
use TBolier\RethinkQL\RethinkInterface;
99
use TBolier\RethinkQL\Types\Term\TermType;
1010

11-
class Skip extends AbstractAggregation
11+
class Skip extends AbstractTransformation
1212
{
1313
/**
1414
* @var int

0 commit comments

Comments
 (0)