mirror of
https://github.com/Intervention/image.git
synced 2025-08-31 09:31:53 +02:00
added countLines method
This commit is contained in:
@@ -233,4 +233,14 @@ abstract class AbstractFont
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts lines of text to be written
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function countLines()
|
||||
{
|
||||
return count(explode(PHP_EOL, $this->text));
|
||||
}
|
||||
}
|
||||
|
@@ -61,4 +61,17 @@ class AbstractFontTest extends PHPUnit_Framework_TestCase
|
||||
$font->file('test.ttf');
|
||||
$this->assertEquals('test.ttf', $font->file);
|
||||
}
|
||||
|
||||
public function testCountLines()
|
||||
{
|
||||
$font = $this->getMockForAbstractClass('\Intervention\Image\AbstractFont');
|
||||
$font->text('foo'.PHP_EOL.'bar'.PHP_EOL.'baz');
|
||||
$this->assertEquals(3, $font->countLines());
|
||||
$font->text("foo\nbar\nbaz");
|
||||
$this->assertEquals(3, $font->countLines());
|
||||
$font->text('foo
|
||||
bar
|
||||
baz');
|
||||
$this->assertEquals(3, $font->countLines());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user