Skip to content

Commit 01fcdc4

Browse files
Merge pull request #37 from TheDragonCode/2.x
Removed sorter manager
2 parents 40f5162 + bd7c588 commit 01fcdc4

8 files changed

Lines changed: 17 additions & 39 deletions

File tree

src/Contracts/Sorter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
interface Sorter
88
{
9-
public static function callback(string $column, int $arrow = 1): callable;
9+
public static function get(string $column, int $arrow = 1): callable;
1010
}

src/Services/MainLogic.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
namespace DragonCode\SizeSorter\Services;
66

77
use DragonCode\SizeSorter\Enum\Group;
8-
use DragonCode\SizeSorter\Sorters\SorterManager;
8+
use DragonCode\SizeSorter\Sorters\ArrowSorter;
9+
use DragonCode\SizeSorter\Sorters\CharSorter;
10+
use DragonCode\SizeSorter\Sorters\NumberSorter;
911
use DragonCode\Support\Helpers\Ables\Stringable;
1012
use Illuminate\Support\Collection as IC;
1113

@@ -73,7 +75,7 @@ protected static function sortChars(IC $values, string $column): IC
7375
protected static function sortSmallSizes(IC $values, string $column): IC
7476
{
7577
return $values->sort(
76-
SorterManager::byArrow($column, -1)
78+
ArrowSorter::get($column, -1)
7779
)
7880
->groupBy(static fn (mixed $size) => static::resolveValue($size, $column)->toString(), true)
7981
->map(static fn (IC $values) => static::sortSpecialChars($values, $column));
@@ -82,21 +84,21 @@ protected static function sortSmallSizes(IC $values, string $column): IC
8284
protected static function sortSpecialChars(IC $values, string $column): IC
8385
{
8486
return $values->sort(
85-
SorterManager::byChars($column)
87+
CharSorter::get($column)
8688
);
8789
}
8890

8991
protected static function sortArrows(IC $values, string $column): IC
9092
{
9193
return $values->sort(
92-
SorterManager::byArrow($column)
94+
ArrowSorter::get($column)
9395
);
9496
}
9597

9698
protected static function sortNumbers(IC $items, string $column): IC
9799
{
98100
return $items->sort(
99-
SorterManager::byNumbers($column)
101+
NumberSorter::get($column)
100102
);
101103
}
102104

src/SizeSorter.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static function items(iterable $items): static
2222

2323
public function __construct(
2424
protected readonly iterable $items,
25-
protected readonly Order $order = new Order()
25+
protected readonly Order $order = new Order
2626
) {}
2727

2828
public function column(string $name): static
@@ -34,7 +34,6 @@ public function column(string $name): static
3434

3535
/**
3636
* @param Group[]|null $order
37-
*
3837
* @return $this
3938
*/
4039
public function orderBy(?array $order): static
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace DragonCode\SizeSorter\Sorters;
66

7-
class Arrow extends Base
7+
class ArrowSorter extends BaseSorter
88
{
9-
public static function callback(string $column, int $arrow = 1): callable
9+
public static function get(string $column, int $arrow = 1): callable
1010
{
1111
return static function (mixed $a, mixed $b) use ($arrow, $column) {
1212
$a = static::key($a, $column);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use DragonCode\SizeSorter\Contracts\Sorter;
88
use DragonCode\SizeSorter\Services\Resolver;
99

10-
abstract class Base implements Sorter
10+
abstract class BaseSorter implements Sorter
1111
{
1212
protected static function key(mixed $value, string $column): mixed
1313
{
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use DragonCode\SizeSorter\Services\Resolver;
88
use DragonCode\SizeSorter\Services\Str;
99

10-
class Chars extends Base
10+
class CharSorter extends BaseSorter
1111
{
12-
public static function callback(string $column, int $arrow = 1): callable
12+
public static function get(string $column, int $arrow = 1): callable
1313
{
1414
return static function (mixed $a, mixed $b) use ($column, $arrow) {
1515
$a = static::key($a, $column);
@@ -23,7 +23,7 @@ public static function callback(string $column, int $arrow = 1): callable
2323

2424
protected static function resolveArrow(int $arrow, string $column): callable
2525
{
26-
return Arrow::callback($column, $arrow);
26+
return ArrowSorter::get($column, $arrow);
2727
}
2828

2929
protected static function contains(string $value, string $needle): bool
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
use DragonCode\SizeSorter\Services\Resolver;
88

9-
class Numbers extends Base
9+
class NumberSorter extends BaseSorter
1010
{
11-
public static function callback(string $column, int $arrow = 1): callable
11+
public static function get(string $column, int $arrow = 1): callable
1212
{
1313
return static function (mixed $a, mixed $b) use ($column, $arrow) {
1414
$a = static::number($a, $column);

src/Sorters/SorterManager.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)