-
-
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: move count strategy resolver to
CountStrategyUtil
(#106)
- Loading branch information
Showing
3 changed files
with
43 additions
and
24 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
39 changes: 39 additions & 0 deletions
39
packages/collections-common/src/Internal/CountStrategyUtil.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,39 @@ | ||
<?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\Domain\Collections\Common\Internal; | ||
|
||
use Rekalogika\Domain\Collections\Common\Configuration; | ||
use Rekalogika\Domain\Collections\Common\Count\ConditionalDelegatedCountStrategy; | ||
use Rekalogika\Domain\Collections\Common\Count\CountStrategy; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class CountStrategyUtil | ||
{ | ||
private function __construct() | ||
{ | ||
} | ||
|
||
public static function getDefaultCountStrategy(): CountStrategy | ||
{ | ||
if (Configuration::$defaultCountStrategy === null) { | ||
$countStrategy = fn (): CountStrategy => new ConditionalDelegatedCountStrategy(); | ||
} else { | ||
$countStrategy = Configuration::$defaultCountStrategy; | ||
} | ||
|
||
return $countStrategy(); | ||
} | ||
} |
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