-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use
configure()
method for subclasses to configure the re…
…pository (#41)
- Loading branch information
Showing
3 changed files
with
115 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
packages/collections-orm/src/Configuration/BasicRepositoryConfiguration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of rekalogika/collections package. | ||
* | ||
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
namespace Rekalogika\Collections\ORM\Configuration; | ||
|
||
use Doctrine\Common\Collections\Order; | ||
use Rekalogika\Domain\Collections\Common\CountStrategy; | ||
|
||
class BasicRepositoryConfiguration | ||
{ | ||
/** | ||
* @var non-empty-array<string,Order>|string|null | ||
*/ | ||
private array|string|null $orderBy = null; | ||
|
||
/** | ||
* @var int<1,max> | ||
*/ | ||
private int $itemsPerPage = 50; | ||
|
||
private CountStrategy $countStrategy = CountStrategy::Restrict; | ||
|
||
/** | ||
* @return non-empty-array<string,Order>|string|null | ||
*/ | ||
public function getOrderBy(): null|array|string | ||
{ | ||
return $this->orderBy; | ||
} | ||
|
||
/** | ||
* @param non-empty-array<string,Order>|string $orderBy | ||
*/ | ||
public function setOrderBy($orderBy): self | ||
{ | ||
$this->orderBy = $orderBy; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return int<1,max> | ||
*/ | ||
public function getItemsPerPage(): int | ||
{ | ||
return $this->itemsPerPage; | ||
} | ||
|
||
/** | ||
* @param int<1,max> $itemsPerPage | ||
*/ | ||
public function setItemsPerPage(int $itemsPerPage): self | ||
{ | ||
$this->itemsPerPage = $itemsPerPage; | ||
|
||
return $this; | ||
} | ||
|
||
public function getCountStrategy(): CountStrategy | ||
{ | ||
return $this->countStrategy; | ||
} | ||
|
||
public function setCountStrategy(CountStrategy $countStrategy): self | ||
{ | ||
$this->countStrategy = $countStrategy; | ||
|
||
return $this; | ||
} | ||
} |