Skip to content

Commit 00aa917

Browse files
authored
feat: replace phpoption/phpoption with azjezz/psl (#46)
azjezz/psl is more adopted within our code bases
1 parent f83ca40 commit 00aa917

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use function Cdn77\Functions\Iterable\find;
5353
$iterable = [0, 1, 2, 3];
5454
$option = find($iterable, static fn (mixed $_, int $value) => $value < 2);
5555

56-
assert($option->get() === 0);
56+
assert($option->unwrap() === 0);
5757
```
5858

5959
[GA Image]: https://github.com/cdn77/PhpFunctions/workflows/CI/badge.svg

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"require": {
2222
"php": "^8.2",
2323
"ext-ds": "*",
24-
"phpoption/phpoption": "^1.9"
24+
"azjezz/psl": "^2.9"
2525
},
2626
"require-dev": {
2727
"cdn77/coding-standard": "^7.0",

src/iterable.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
namespace Cdn77\Functions\Iterable;
66

7-
use PhpOption\None;
8-
use PhpOption\Option;
9-
use PhpOption\Some;
7+
use Psl\Option\Option;
108

119
/**
1210
* @param iterable<K, T> $iterable
@@ -21,9 +19,9 @@ function find(iterable $iterable, callable $filterFn): Option
2119
{
2220
foreach ($iterable as $k => $v) {
2321
if ($filterFn($k, $v)) {
24-
return new Some($v);
22+
return Option::some($v);
2523
}
2624
}
2725

28-
return None::create();
26+
return Option::none();
2927
}

tests/IterableTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Cdn77\Functions\Tests;
66

7-
use PhpOption\None;
87
use PHPUnit\Framework\Attributes\CoversFunction;
98
use PHPUnit\Framework\TestCase;
109

@@ -18,14 +17,14 @@ public function testFindFirst(): void
1817
$iterable = [0, 1, 2, 3];
1918
$option = find($iterable, static fn (mixed $_, int $value) => $value < 2);
2019

21-
self::assertSame(0, $option->getOrElse(null));
20+
self::assertSame(0, $option->unwrapOr(null));
2221
}
2322

2423
public function testDontFind(): void
2524
{
2625
$iterable = [0, 1, 2, 3];
2726
$option = find($iterable, static fn (mixed $_, int $value) => $value > 3);
2827

29-
self::assertSame(None::create(), $option);
28+
self::assertTrue($option->isNone());
3029
}
3130
}

0 commit comments

Comments
 (0)