Skip to content

Commit b3444c4

Browse files
committed
#3 Allow to extend DbFilter class
- Fix static construction - Fix return Types
1 parent 56aceb8 commit b3444c4

4 files changed

Lines changed: 30 additions & 30 deletions

File tree

src/filters/DbFilter.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,66 +37,66 @@ private function __construct(string $column, $value, string $type)
3737
* DbFilter constructor.
3838
* @param string $column
3939
* @param string|int|array $value
40-
* @return DbFilter
40+
* @return Filter
4141
*/
42-
public static function constructLike(string $column, $value): self
42+
public static function constructLike(string $column, $value): Filter
4343
{
44-
return new self($column, $value, DbFilterType::Like);
44+
return new static($column, $value, DbFilterType::Like);
4545
}
4646

4747
/**
4848
* DbFilter constructor.
4949
* @param string $column
5050
* @param string|int|array $value
51-
* @return DbFilter
51+
* @return Filter
5252
*/
53-
public static function constructNotLike(string $column, $value): self
53+
public static function constructNotLike(string $column, $value): Filter
5454
{
55-
return new self($column, $value, DbFilterType::NotLike);
55+
return new static($column, $value, DbFilterType::NotLike);
5656
}
5757

5858
/**
5959
* DbFilter constructor.
6060
* @param string $column
6161
* @param string|int|array $value
62-
* @return DbFilter
62+
* @return Filter
6363
*/
64-
public static function constructEquals(string $column, $value): self
64+
public static function constructEquals(string $column, $value): Filter
6565
{
66-
return new self($column, $value, DbFilterType::Equals);
66+
return new static($column, $value, DbFilterType::Equals);
6767
}
6868

6969
/**
7070
* DbFilter constructor.
7171
* @param string $column
7272
* @param string|int|array $value
73-
* @return DbFilter
73+
* @return Filter
7474
*/
75-
public static function constructNotEquals(string $column, $value): self
75+
public static function constructNotEquals(string $column, $value): Filter
7676
{
77-
return new self($column, $value, DbFilterType::NotEquals);
77+
return new static($column, $value, DbFilterType::NotEquals);
7878
}
7979

8080
/**
8181
* DbFilter constructor.
8282
* @param string $column
8383
* @param string|int|array $value
84-
* @return DbFilter
84+
* @return Filter
8585
*/
86-
public static function constructIn(string $column, $value): self
86+
public static function constructIn(string $column, $value): Filter
8787
{
88-
return new self($column, $value, DbFilterType::In);
88+
return new static($column, $value, DbFilterType::In);
8989
}
9090

9191
/**
9292
* DbFilter constructor.
9393
* @param string $column
9494
* @param string|int|array $value
95-
* @return DbFilter
95+
* @return Filter
9696
*/
97-
public static function constructNotIn(string $column, $value): self
97+
public static function constructNotIn(string $column, $value): Filter
9898
{
99-
return new self($column, $value, DbFilterType::NotEquals);
99+
return new static($column, $value, DbFilterType::NotEquals);
100100
}
101101

102102
public function sql(): string

src/filters/DbFilters.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ public function __construct(DbFiltersGroup $filtersGroup)
1515
$this->filtersGroup = $filtersGroup;
1616
}
1717

18-
public static function constructFromGroup(DbFiltersGroup $filtersGroup): self
18+
public static function constructFromGroup(DbFiltersGroup $filtersGroup): Filter
1919
{
20-
return new self($filtersGroup);
20+
return new static($filtersGroup);
2121
}
2222

23-
public static function constructFromFilter(Filter $dbFilter): self
23+
public static function constructFromFilter(Filter $dbFilter): Filter
2424
{
25-
return new self(DbFiltersGroup::constructAndGroup([$dbFilter]));
25+
return new static(DbFiltersGroup::constructAndGroup([$dbFilter]));
2626
}
2727

2828
public function sql(): string

src/filters/DbFiltersGroup.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ private function __construct(array $filters, string $join)
2929

3030
/**
3131
* @param Filter[]|DbFiltersGroup[] $filters
32-
* @return DbFiltersGroup
32+
* @return Filter
3333
*/
34-
public static function constructAndGroup(array $filters): self
34+
public static function constructAndGroup(array $filters): Filter
3535
{
36-
return new self($filters, 'AND');
36+
return new static($filters, 'AND');
3737
}
3838

3939
/**
4040
* @param Filter[]|DbFiltersGroup[] $filters
41-
* @return DbFiltersGroup
41+
* @return Filter
4242
*/
43-
public static function constructOrGroup(array $filters): self
43+
public static function constructOrGroup(array $filters): Filter
4444
{
45-
return new self($filters, 'OR');
45+
return new static($filters, 'OR');
4646
}
4747

4848
public function sql(): string

src/order/DbOrder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public function __construct(array $columnOrdering)
1818
$this->ordering = $columnOrdering;
1919
}
2020

21-
public static function fromSingleColumn(string $column, string $direction)
21+
public static function fromSingleColumn(string $column, string $direction): Order
2222
{
23-
return new self([$column => $direction]);
23+
return new static([$column => $direction]);
2424
}
2525

2626
public function orderingFormatted(): string

0 commit comments

Comments
 (0)