Skip to content

Commit 2b5e8ea

Browse files
committed
Add writeln function
1 parent 9162c4c commit 2b5e8ea

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"src/Fp/Functions/Evidence/ProveString.php",
9797
"src/Fp/Functions/Util/JsonDecode.php",
9898
"src/Fp/Functions/Util/RegExp.php",
99+
"src/Fp/Functions/Util/Writeln.php",
99100
"src/Fp/Functions/Panic.php",
100101
"src/Fp/Functions/Id.php",
101102
"src/Fp/Functions/Unit.php"

src/Fp/Functions/Util/Writeln.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Fp\Util;
6+
7+
use const PHP_EOL;
8+
9+
function writeln(string $text): void
10+
{
11+
print_r($text . PHP_EOL);
12+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests\Runtime\Functions\Util;
6+
7+
use Fp\Functional\Option\Option;
8+
use PHPUnit\Framework\TestCase;
9+
10+
use function Fp\Util\regExpMatch;
11+
use function Fp\Util\writeln;
12+
use const PHP_EOL;
13+
14+
final class WritelnTest extends TestCase
15+
{
16+
public function testWriteln(): void
17+
{
18+
writeln('Hi!');
19+
$this->expectOutputString('Hi!' . PHP_EOL);
20+
}
21+
}

0 commit comments

Comments
 (0)