Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
- space after opening comment
- removed a conditional by rephrasing and returning in the conditional
  body
  • Loading branch information
weierophinney committed Mar 4, 2014
1 parent c420065 commit 4c59281
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,26 +311,25 @@ public function writeTextBlock(
throw new Exception\InvalidArgumentException('Invalid height supplied.');
}

//ensure the text is not wider than the width
if (strlen($text) > $width) {
$text = wordwrap($text, $width, PHP_EOL, true);
} else {
//just write the line at the spec'd position
// ensure the text is not wider than the width
if (strlen($text) <= $width) {
// just write the line at the spec'd position
$this->setPos($x, $y);
$this->write($text, $color, $bgColor);

return;
}

//convert to array of lines
$text = wordwrap($text, $width, PHP_EOL, true);

// convert to array of lines
$lines = explode(PHP_EOL, $text);

//truncate if height was specified
// truncate if height was specified
if (null !== $height && count($lines) > $height) {
$lines = array_slice($lines, 0, $height);
}

//write each line
// write each line
$curY = $y;
foreach ($lines as $line) {
$this->setPos($x, $curY);
Expand Down

0 comments on commit 4c59281

Please sign in to comment.