Skip to content

Commit

Permalink
Merge pull request #34 from CSchlipp/feature/printOptions
Browse files Browse the repository at this point in the history
Add PrintOptions Command
  • Loading branch information
RamyTalal authored Sep 23, 2023
2 parents c4798c4 + d3ae8ff commit 0f389bd
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Command/PrintOptions.php
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');
}
}

20 changes: 20 additions & 0 deletions tests/Command/PrintOptionsTest.php
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()));
}
}

0 comments on commit 0f389bd

Please sign in to comment.