This repository has been archived by the owner on Apr 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
368 additions
and
101 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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,55 @@ | ||
<?php | ||
|
||
namespace BigFish\PDF417\Renderers; | ||
|
||
use BigFish\PDF417\BarcodeData; | ||
use BigFish\PDF417\RendererInterface; | ||
|
||
abstract class AbstractRenderer implements RendererInterface | ||
{ | ||
/** Default options array. */ | ||
protected $options = []; | ||
|
||
public function __construct(array $options = []) | ||
{ | ||
// Merge options with defaults, ignore options not specified in | ||
// defaults. | ||
foreach ($options as $key => $value) { | ||
if (isset($this->options[$key])) { | ||
$this->options[$key] = $value; | ||
} | ||
} | ||
|
||
$errors = $this->validateOptions(); | ||
if (!empty($errors)) { | ||
$errors = implode("\n", $errors); | ||
throw new \InvalidArgumentException($errors); | ||
} | ||
} | ||
|
||
/** | ||
* Validates the options, throws an Exception on failure. | ||
* | ||
* @param array $options | ||
* @return array An array of errors, empty if no errors. | ||
*/ | ||
public function validateOptions() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Returns the MIME content type of the barcode generated by this renderer. | ||
* | ||
* @return string | ||
*/ | ||
public abstract function getContentType(); | ||
|
||
/** | ||
* Renders the barcode from the given data set. | ||
* | ||
* @param BarcodeData $data The barcode data. | ||
* @return mixed Output format depends on the renderer. | ||
*/ | ||
public abstract function render(BarcodeData $data); | ||
} |
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
Oops, something went wrong.