mirror of
https://github.com/Intervention/image.git
synced 2025-08-20 04:31:24 +02:00
Improve TextBlock code & test
This commit is contained in:
@@ -23,6 +23,12 @@ class TextBlock extends Collection
|
|||||||
return $this->items;
|
return $this->items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get line by given key
|
||||||
|
*
|
||||||
|
* @param mixed $key
|
||||||
|
* @return null|Line
|
||||||
|
*/
|
||||||
public function line($key): ?Line
|
public function line($key): ?Line
|
||||||
{
|
{
|
||||||
if (!array_key_exists($key, $this->lines())) {
|
if (!array_key_exists($key, $this->lines())) {
|
||||||
|
@@ -35,6 +35,7 @@ class TextBlockTest extends TestCase
|
|||||||
$this->assertEquals('foo', $block->line(0));
|
$this->assertEquals('foo', $block->line(0));
|
||||||
$this->assertEquals('FooBar', $block->line(1));
|
$this->assertEquals('FooBar', $block->line(1));
|
||||||
$this->assertEquals('bar', $block->line(2));
|
$this->assertEquals('bar', $block->line(2));
|
||||||
|
$this->assertNull($block->line(20));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLongestLine(): void
|
public function testLongestLine(): void
|
||||||
|
Reference in New Issue
Block a user