19declare(strict_types=1);
26use PHPUnit\Framework\TestCase;
27use UnexpectedValueException;
38 $result = $listTransformation->transform([
'hello',
'world']);
40 $this->assertEquals([
'hello',
'world'], $result);
46 $this->assertSame([], $listTransformation->transform([]));
52 $result = $listTransformation->applyTo(
new Ok([]));
53 $this->assertFalse($result->isError());
58 $this->expectNotToPerformAssertions();
62 $result = $listTransformation->transform(
null);
63 }
catch (UnexpectedValueException $exception) {
73 $result = $listTransformation->applyTo(
new Ok(
null));
74 $this->assertTrue($result->isError());
80 $this->expectNotToPerformAssertions();
85 $result = $listTransformation->transform([
'hello', 2]);
86 }
catch (UnexpectedValueException $exception) {
97 $result = $listTransformation->applyTo(
new Ok([
'hello',
'world']));
99 $this->assertEquals([
'hello',
'world'], $result->value());
100 $this->assertTrue($result->isOK());
107 $result = $listTransformation->applyTo(
new Ok([
'hello', 2]));
109 $this->assertTrue($result->isError());
A result encapsulates a value or an error and simplifies the handling of those.