Skip to content

Commit e132aa6

Browse files
tboliermarcgeurts
authored andcommitted
Add transformation compound return types and add valuable unit tests
1 parent 29620e4 commit e132aa6

18 files changed

+369
-118
lines changed

src/Query/Aggregation/AbstractAggregation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@ public function count(): QueryInterface
1919
/**
2020
* @inheritdoc
2121
*/
22-
public function sum($key): QueryInterface
22+
public function sum(string $key): QueryInterface
2323
{
2424
return new Sum($this->rethink, $this->message, $this, $key);
2525
}
2626

2727
/**
2828
* @inheritdoc
2929
*/
30-
public function avg($key): QueryInterface
30+
public function avg(string $key): QueryInterface
3131
{
3232
return new Avg($this->rethink, $this->message, $this, $key);
3333
}
3434

3535
/**
3636
* @inheritdoc
3737
*/
38-
public function min($key): AggregationInterface
38+
public function min(string $key): AggregationInterface
3939
{
4040
return new Min($this->rethink, $this->message, $this, $key);
4141
}
4242

4343
/**
4444
* @inheritdoc
4545
*/
46-
public function max($key): AggregationInterface
46+
public function max(string $key): AggregationInterface
4747
{
4848
return new Max($this->rethink, $this->message, $this, $key);
4949
}

src/Query/Aggregation/AggregationInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ public function count(): QueryInterface;
1717
* @param string $key
1818
* @return QueryInterface
1919
*/
20-
public function sum($key): QueryInterface;
20+
public function sum(string $key): QueryInterface;
2121

2222
/**
2323
* @param string $key
2424
* @return QueryInterface
2525
*/
26-
public function avg($key): QueryInterface;
26+
public function avg(string $key): QueryInterface;
2727

2828
/**
2929
* @param string $key
3030
* @return AggregationInterface
3131
*/
32-
public function min($key): AggregationInterface;
32+
public function min(string $key): AggregationInterface;
3333

3434
/**
3535
* @param string $key
3636
* @return AggregationInterface
3737
*/
38-
public function max($key): AggregationInterface;
38+
public function max(string $key): AggregationInterface;
3939

4040
/**
4141
* @return Iterable|ResponseInterface

src/Query/Operation/AbstractOperation.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace TBolier\RethinkQL\Query\Operation;
55

66
use TBolier\RethinkQL\Query\Aggregation\AbstractAggregation;
7+
use TBolier\RethinkQL\Query\Transformation\TransformationCompoundInterface;
78
use TBolier\RethinkQL\Query\QueryInterface;
89

910
abstract class AbstractOperation extends AbstractAggregation implements OperationInterface
@@ -19,15 +20,15 @@ public function delete(): QueryInterface
1920
/**
2021
* @inheritdoc
2122
*/
22-
public function filter(array $predicate): OperationInterface
23+
public function filter(array $predicate): TransformationCompoundInterface
2324
{
2425
return new Filter($this->rethink, $this->message, $this, $predicate);
2526
}
2627

2728
/**
2829
* @inheritdoc
2930
*/
30-
public function getAll(...$keys): OperationInterface
31+
public function getAll(...$keys): TransformationCompoundInterface
3132
{
3233
return new GetAll($this->rethink, $this->message, $this, $keys);
3334
}

src/Query/Operation/GetAll.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55

66
use TBolier\RethinkQL\Message\MessageInterface;
77
use TBolier\RethinkQL\Query\QueryInterface;
8+
use TBolier\RethinkQL\Query\Transformation\AbstractTransformationCompound;
89
use TBolier\RethinkQL\RethinkInterface;
910
use TBolier\RethinkQL\Types\Term\TermType;
1011

11-
class GetAll extends AbstractOperation
12+
class GetAll extends AbstractTransformationCompound
1213
{
1314
/**
1415
* @var array

src/Query/Operation/OperationInterface.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use TBolier\RethinkQL\Query\Aggregation\AggregationInterface;
77
use TBolier\RethinkQL\Query\QueryInterface;
8+
use TBolier\RethinkQL\Query\Transformation\TransformationCompoundInterface;
89
use TBolier\RethinkQL\Response\ResponseInterface;
910

1011
interface OperationInterface extends AggregationInterface
@@ -16,15 +17,15 @@ public function delete(): QueryInterface;
1617

1718
/**
1819
* @param array $predicate
19-
* @return OperationInterface
20+
* @return TransformationCompoundInterface
2021
*/
21-
public function filter(array $predicate): OperationInterface;
22+
public function filter(array $predicate): TransformationCompoundInterface;
2223

2324
/**
2425
* @param int|string|array $keys
25-
* @return OperationInterface
26+
* @return TransformationCompoundInterface
2627
*/
27-
public function getAll(...$keys): OperationInterface;
28+
public function getAll(...$keys): TransformationCompoundInterface;
2829

2930
/**
3031
* @param array $elements

src/Query/Transformation/AbstractTransformation.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ public function isEmpty(): QueryInterface
1919
/**
2020
* @inheritdoc
2121
*/
22-
public function limit($value): TransformationInterface
22+
public function limit($value): TransformationCompoundInterface
2323
{
2424
return new Limit($this->rethink, $this->message, $this, $value);
2525
}
2626

2727
/**
2828
* @inheritdoc
2929
*/
30-
public function skip($value): TransformationInterface
30+
public function skip($value): TransformationCompoundInterface
3131
{
3232
return new Skip($this->rethink, $this->message, $this, $value);
3333
}
3434

3535
/**
3636
* @inheritdoc
3737
*/
38-
public function orderBy($key): TransformationInterface
38+
public function orderBy($key): TransformationCompoundInterface
3939
{
4040
return new OrderBy($this->rethink, $this->message, $this, $key);
4141
}

src/Query/Transformation/AbstractTransformationCompound.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use TBolier\RethinkQL\Query\Operation\AbstractOperation;
77
use TBolier\RethinkQL\Query\QueryInterface;
88

9-
abstract class AbstractTransformationCompound extends AbstractOperation implements TransformationInterface
9+
abstract class AbstractTransformationCompound extends AbstractOperation implements TransformationCompoundInterface
1010
{
1111
/**
1212
* @inheritdoc
@@ -19,23 +19,23 @@ public function isEmpty(): QueryInterface
1919
/**
2020
* @inheritdoc
2121
*/
22-
public function limit($value): TransformationInterface
22+
public function limit($value): TransformationCompoundInterface
2323
{
2424
return new Limit($this->rethink, $this->message, $this, $value);
2525
}
2626

2727
/**
2828
* @inheritdoc
2929
*/
30-
public function skip($value): TransformationInterface
30+
public function skip($value): TransformationCompoundInterface
3131
{
3232
return new Skip($this->rethink, $this->message, $this, $value);
3333
}
3434

3535
/**
3636
* @inheritdoc
3737
*/
38-
public function orderBy($key): TransformationInterface
38+
public function orderBy($key): TransformationCompoundInterface
3939
{
4040
return new OrderBy($this->rethink, $this->message, $this, $key);
4141
}

src/Query/Transformation/Limit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use TBolier\RethinkQL\RethinkInterface;
99
use TBolier\RethinkQL\Types\Term\TermType;
1010

11-
class Limit extends AbstractTransformation
11+
class Limit extends AbstractTransformationCompound
1212
{
1313
/**
1414
* @var int

src/Query/Transformation/OrderBy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use TBolier\RethinkQL\RethinkInterface;
99
use TBolier\RethinkQL\Types\Term\TermType;
1010

11-
class OrderBy extends AbstractTransformation
11+
class OrderBy extends AbstractTransformationCompound
1212
{
1313
/**
1414
* @var mixed|QueryInterface

src/Query/Transformation/Skip.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use TBolier\RethinkQL\RethinkInterface;
99
use TBolier\RethinkQL\Types\Term\TermType;
1010

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

0 commit comments

Comments
 (0)