From 83113f600480689d6de3d0842905bc888e36aa4a Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sun, 14 Jan 2024 10:53:19 +0100 Subject: [PATCH] Improve TextBlock code & test --- src/Typography/TextBlock.php | 6 ++++++ tests/Typography/TextBlockTest.php | 1 + 2 files changed, 7 insertions(+) diff --git a/src/Typography/TextBlock.php b/src/Typography/TextBlock.php index f83a7dc4..2eea0f13 100644 --- a/src/Typography/TextBlock.php +++ b/src/Typography/TextBlock.php @@ -23,6 +23,12 @@ class TextBlock extends Collection return $this->items; } + /** + * Get line by given key + * + * @param mixed $key + * @return null|Line + */ public function line($key): ?Line { if (!array_key_exists($key, $this->lines())) { diff --git a/tests/Typography/TextBlockTest.php b/tests/Typography/TextBlockTest.php index 60f7cf35..4f8cad43 100644 --- a/tests/Typography/TextBlockTest.php +++ b/tests/Typography/TextBlockTest.php @@ -35,6 +35,7 @@ class TextBlockTest extends TestCase $this->assertEquals('foo', $block->line(0)); $this->assertEquals('FooBar', $block->line(1)); $this->assertEquals('bar', $block->line(2)); + $this->assertNull($block->line(20)); } public function testLongestLine(): void