1
0
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:
Oliver Vogel
2014-07-23 18:29:50 +02:00
parent fc0c202772
commit 968728d84b
2 changed files with 23 additions and 0 deletions

View File

@@ -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));
}
}

View File

@@ -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());
}
}