1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-18 19:51:22 +02:00

Improve TextBlock code & test

This commit is contained in:
Oliver Vogel
2024-01-14 10:53:19 +01:00
parent a7ec9746fa
commit 83113f6004
2 changed files with 7 additions and 0 deletions

View File

@@ -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())) {

View File

@@ -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