-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EAN-13 has its own class. Will probably add some Reflection Class met…
…hods to load this object dynamically. Whole thing needs refactoring.
- Loading branch information
rlt3
committed
Oct 30, 2012
1 parent
9086aa4
commit 6ea7c5f
Showing
3 changed files
with
230 additions
and
135 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 |
---|---|---|
@@ -1,23 +1,38 @@ | ||
<?php | ||
//autoload | ||
include("ean.php"); | ||
|
||
class Barcode | ||
{ | ||
public $code; | ||
public $type; | ||
public $number; | ||
public $encoding; | ||
public $scale; | ||
|
||
function __construct($code=null, $type='EAN-13') | ||
protected $_encoder; | ||
|
||
function __construct($encoding, $number=null, $scale=null) | ||
{ | ||
$this->code = (isset($code)) ? $code : self::randomCode(); | ||
$this->number = ($number==null) ? $this->_random() : $number; | ||
$this->scale = ($scale==null || $scale<4) ? 4 : $scale; | ||
|
||
// Reflection Class : Method | ||
|
||
$this->_encoder = new EAN13($this->number, $this->scale); | ||
} | ||
|
||
encode($this->code); | ||
function __destruct() | ||
{ | ||
$this->_encoder->display(); | ||
} | ||
|
||
private static function randomCode() | ||
private function _random() | ||
{ | ||
return substr(number_format(time() * rand(),0,'',''),0,12); | ||
} | ||
} | ||
|
||
$number = (isset($_GET['code'])) ? $_GET['code'] : null; | ||
new Barcode($number); | ||
$encoding = (isset($_GET['encoding'])) ? $_GET['encoding'] : 'EAN-13'; | ||
$number = (isset($_GET['code'])) ? $_GET['code'] : null; | ||
$scale = (isset($_GET['scale'])) ? $_GET['scale'] : null; | ||
|
||
new Barcode($encoding, $number, $scale); |
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.