picqer / php-barcode-generator

Barcode generator in PHP that is easy to use, non-bloated and framework independent.
GNU Lesser General Public License v3.0
1.67k stars 402 forks source link

Code style: undefined method Picqer\Barcode\BarcodeGenerator::getBarcode() #102

Closed Axent96 closed 4 years ago

Axent96 commented 4 years ago

Each generator extends from "BarcodeGenerator" without some interface. For this case we need the abstract function "getBarcode" or some general interface for the generators:

use Picqer\Barcode\BarcodeGeneratorHTML; use Picqer\Barcode\BarcodeGeneratorJPG; use Picqer\Barcode\BarcodeGeneratorPNG; use Picqer\Barcode\BarcodeGeneratorSVG;

phpstan say:

Call to an undefined method Picqer\Barcode\BarcodeGenerator::getBarcode().

casperbakker commented 4 years ago

Yes, it would be better to have some interface or not extend from the base generator. I played with this with version 2.0, but the image generators (jpg and png) have other options and naming then the vector based generators (html and svg). That is why I could not make the interface the same.

With version 2 I started some refactoring to make it possible to feed the barcode type class directly into the generators. Then there is no central class or factory where everything should be the same. Then the image and vector generators can have a slight different interface.

If someone has a better idea, please let me know.