-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from CSchlipp/feature/printOptions
Add PrintOptions Command
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Talal\LabelPrinter\Command; | ||
|
||
class PrintOptions implements CommandInterface | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
protected $optimizeQuality; | ||
|
||
/** | ||
* @param bool $optimizeQuality | ||
*/ | ||
public function __construct($optimizeQuality = false) | ||
{ | ||
$this->optimizeQuality = $optimizeQuality; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function read() | ||
{ | ||
return '^QS' . ($this->optimizeQuality ? '1' : '0'); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
use Talal\LabelPrinter\Command; | ||
|
||
class PrintOptionsTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testEnabled() | ||
{ | ||
$command = new Command\PrintOptions(true); | ||
|
||
$this->assertEquals('5e515331', bin2hex($command->read())); | ||
} | ||
|
||
public function testDisabled() | ||
{ | ||
$command = new Command\PrintOptions(false); | ||
|
||
$this->assertEquals('5e515330', bin2hex($command->read())); | ||
} | ||
} |