Subiendo proyecto completo sin restricciones de git ignore
This commit is contained in:
127
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/BTC.php
vendored
Normal file
127
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/BTC.php
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace SimpleSoftwareIO\QrCode\DataTypes;
|
||||
|
||||
class BTC implements DataTypeInterface
|
||||
{
|
||||
/**
|
||||
* The prefix of the QrCode.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix = 'bitcoin:';
|
||||
|
||||
/**
|
||||
* The BitCoin address.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $address;
|
||||
|
||||
/**
|
||||
* The amount to send.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $amount;
|
||||
|
||||
/**
|
||||
* The BitCoin transaction label.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label;
|
||||
|
||||
/**
|
||||
* The BitCoin message to send.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $message;
|
||||
|
||||
/**
|
||||
* The BitCoin return URL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $returnAddress;
|
||||
|
||||
/**
|
||||
* Generates the DataType Object and sets all of its properties.
|
||||
*
|
||||
* @param $arguments
|
||||
*/
|
||||
public function create(array $arguments)
|
||||
{
|
||||
$this->setProperties($arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the correct QrCode format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->buildBitCoinString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the BitCoin arguments.
|
||||
*
|
||||
* @param array $arguments
|
||||
*/
|
||||
protected function setProperties(array $arguments)
|
||||
{
|
||||
if (isset($arguments[0])) {
|
||||
$this->address = $arguments[0];
|
||||
}
|
||||
|
||||
if (isset($arguments[1])) {
|
||||
$this->amount = $arguments[1];
|
||||
}
|
||||
|
||||
if (isset($arguments[2])) {
|
||||
$this->setOptions($arguments[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the optional BitCoin options.
|
||||
*
|
||||
* @param array $options
|
||||
*/
|
||||
protected function setOptions(array $options)
|
||||
{
|
||||
if (isset($options['label'])) {
|
||||
$this->label = $options['label'];
|
||||
}
|
||||
|
||||
if (isset($options['message'])) {
|
||||
$this->message = $options['message'];
|
||||
}
|
||||
|
||||
if (isset($options['returnAddress'])) {
|
||||
$this->returnAddress = $options['returnAddress'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a BitCoin string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildBitCoinString()
|
||||
{
|
||||
$query = http_build_query([
|
||||
'amount' => $this->amount,
|
||||
'label' => $this->label,
|
||||
'message' => $this->message,
|
||||
'r' => $this->returnAddress,
|
||||
]);
|
||||
|
||||
$btc = $this->prefix.$this->address.'?'.$query;
|
||||
|
||||
return $btc;
|
||||
}
|
||||
}
|
||||
18
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/DataTypeInterface.php
vendored
Normal file
18
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/DataTypeInterface.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace SimpleSoftwareIO\QrCode\DataTypes;
|
||||
|
||||
interface DataTypeInterface
|
||||
{
|
||||
/**
|
||||
* Generates the DataType Object and sets all of its properties.
|
||||
*/
|
||||
public function create(array $arguments);
|
||||
|
||||
/**
|
||||
* Returns the correct QrCode format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString();
|
||||
}
|
||||
122
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/Email.php
vendored
Normal file
122
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/Email.php
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace SimpleSoftwareIO\QrCode\DataTypes;
|
||||
|
||||
use BaconQrCode\Exception\InvalidArgumentException;
|
||||
|
||||
class Email implements DataTypeInterface
|
||||
{
|
||||
/**
|
||||
* The prefix of the QrCode.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix = 'mailto:';
|
||||
|
||||
/**
|
||||
* The email address.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $email;
|
||||
|
||||
/**
|
||||
* The subject of the email.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $subject;
|
||||
|
||||
/**
|
||||
* The body of an email.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $body;
|
||||
|
||||
/**
|
||||
* Generates the DataType Object and sets all of its properties.
|
||||
*
|
||||
* @param $arguments
|
||||
*/
|
||||
public function create(array $arguments)
|
||||
{
|
||||
$this->setProperties($arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the correct QrCode format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->buildEmailString();
|
||||
}
|
||||
|
||||
/*
|
||||
* Builds the email string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildEmailString()
|
||||
{
|
||||
$email = $this->prefix.$this->email;
|
||||
|
||||
if (isset($this->subject) || isset($this->body)) {
|
||||
$data = [
|
||||
'subject' => $this->subject,
|
||||
'body' => $this->body,
|
||||
];
|
||||
$email .= '?'.http_build_query($data);
|
||||
}
|
||||
|
||||
return $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the objects properties.
|
||||
*
|
||||
* @param $arguments
|
||||
*/
|
||||
protected function setProperties(array $arguments)
|
||||
{
|
||||
if (isset($arguments[0])) {
|
||||
$this->setEmail($arguments[0]);
|
||||
}
|
||||
if (isset($arguments[1])) {
|
||||
$this->subject = $arguments[1];
|
||||
}
|
||||
if (isset($arguments[2])) {
|
||||
$this->body = $arguments[2];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the email property.
|
||||
*
|
||||
* @param $email
|
||||
*/
|
||||
protected function setEmail($email)
|
||||
{
|
||||
if ($this->isValidEmail($email)) {
|
||||
$this->email = $email;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures an email is valid.
|
||||
*
|
||||
* @param string $email
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isValidEmail($email)
|
||||
{
|
||||
if (! filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
throw new InvalidArgumentException('Invalid email provided');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
55
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/Geo.php
vendored
Normal file
55
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/Geo.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace SimpleSoftwareIO\QrCode\DataTypes;
|
||||
|
||||
class Geo implements DataTypeInterface
|
||||
{
|
||||
/**
|
||||
* The prefix of the QrCode.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix = 'geo:';
|
||||
|
||||
/**
|
||||
* The separator between the variables.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $separator = ',';
|
||||
|
||||
/**
|
||||
* The latitude.
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
protected $latitude;
|
||||
|
||||
/**
|
||||
* The longitude.
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
protected $longitude;
|
||||
|
||||
/**
|
||||
* Generates the DataType Object and sets all of its properties.
|
||||
*
|
||||
* @param $arguments
|
||||
*/
|
||||
public function create(array $arguments)
|
||||
{
|
||||
$this->latitude = $arguments[0];
|
||||
$this->longitude = $arguments[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the correct QrCode format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->prefix.$this->latitude.$this->separator.$this->longitude;
|
||||
}
|
||||
}
|
||||
40
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/PhoneNumber.php
vendored
Normal file
40
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/PhoneNumber.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace SimpleSoftwareIO\QrCode\DataTypes;
|
||||
|
||||
class PhoneNumber implements DataTypeInterface
|
||||
{
|
||||
/**
|
||||
* The prefix of the QrCode.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix = 'tel:';
|
||||
|
||||
/**
|
||||
* The phone number.
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
protected $phoneNumber;
|
||||
|
||||
/**
|
||||
* Generates the DataType Object and sets all of its properties.
|
||||
*
|
||||
* @param $arguments
|
||||
*/
|
||||
public function create(array $arguments)
|
||||
{
|
||||
$this->phoneNumber = $arguments[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the correct QrCode format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->prefix.$this->phoneNumber;
|
||||
}
|
||||
}
|
||||
85
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/SMS.php
vendored
Normal file
85
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/SMS.php
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace SimpleSoftwareIO\QrCode\DataTypes;
|
||||
|
||||
class SMS implements DataTypeInterface
|
||||
{
|
||||
/**
|
||||
* The prefix of the QrCode.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix = 'sms:';
|
||||
|
||||
/**
|
||||
* The separator between the variables.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $separator = '&body=';
|
||||
|
||||
/**
|
||||
* The phone number.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $phoneNumber;
|
||||
|
||||
/**
|
||||
* The SMS message.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $message;
|
||||
|
||||
/**
|
||||
* Generates the DataType Object and sets all of its properties.
|
||||
*
|
||||
* @param $arguments
|
||||
*/
|
||||
public function create(array $arguments)
|
||||
{
|
||||
$this->setProperties($arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the correct QrCode format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->buildSMSString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the phone number and message for a sms message.
|
||||
*
|
||||
* @param array $arguments
|
||||
*/
|
||||
protected function setProperties(array $arguments)
|
||||
{
|
||||
if (isset($arguments[0])) {
|
||||
$this->phoneNumber = $arguments[0];
|
||||
}
|
||||
if (isset($arguments[1])) {
|
||||
$this->message = $arguments[1];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a SMS string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildSMSString()
|
||||
{
|
||||
$sms = $this->prefix.$this->phoneNumber;
|
||||
|
||||
if (isset($this->message)) {
|
||||
$sms .= $this->separator.$this->message;
|
||||
}
|
||||
|
||||
return $sms;
|
||||
}
|
||||
}
|
||||
115
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/WiFi.php
vendored
Normal file
115
vendor/simplesoftwareio/simple-qrcode/src/DataTypes/WiFi.php
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace SimpleSoftwareIO\QrCode\DataTypes;
|
||||
|
||||
class WiFi implements DataTypeInterface
|
||||
{
|
||||
/**
|
||||
* The prefix of the QrCode.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix = 'WIFI:';
|
||||
|
||||
/**
|
||||
* The separator between the variables.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $separator = ';';
|
||||
|
||||
/**
|
||||
* The encryption of the network. WEP or WPA.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $encryption;
|
||||
|
||||
/**
|
||||
* The SSID of the WiFi network.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $ssid;
|
||||
|
||||
/**
|
||||
* The password of the network.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $password;
|
||||
|
||||
/**
|
||||
* Whether the network is a hidden SSID or not.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $hidden;
|
||||
|
||||
/**
|
||||
* Generates the DataType Object and sets all of its properties.
|
||||
*
|
||||
* @param $arguments
|
||||
*/
|
||||
public function create(array $arguments)
|
||||
{
|
||||
$this->setProperties($arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the correct QrCode format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->buildWifiString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the WiFi string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildWifiString()
|
||||
{
|
||||
$wifi = $this->prefix;
|
||||
|
||||
if (isset($this->encryption)) {
|
||||
$wifi .= 'T:'.$this->encryption.$this->separator;
|
||||
}
|
||||
if (isset($this->ssid)) {
|
||||
$wifi .= 'S:'.$this->ssid.$this->separator;
|
||||
}
|
||||
if (isset($this->password)) {
|
||||
$wifi .= 'P:'.$this->password.$this->separator;
|
||||
}
|
||||
if (isset($this->hidden)) {
|
||||
$wifi .= 'H:'.$this->hidden.$this->separator;
|
||||
}
|
||||
|
||||
return $wifi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the WiFi properties.
|
||||
*
|
||||
* @param $arguments
|
||||
*/
|
||||
protected function setProperties(array $arguments)
|
||||
{
|
||||
$arguments = $arguments[0];
|
||||
if (isset($arguments['encryption'])) {
|
||||
$this->encryption = $arguments['encryption'];
|
||||
}
|
||||
if (isset($arguments['ssid'])) {
|
||||
$this->ssid = $arguments['ssid'];
|
||||
}
|
||||
if (isset($arguments['password'])) {
|
||||
$this->password = $arguments['password'];
|
||||
}
|
||||
if (isset($arguments['hidden'])) {
|
||||
$this->hidden = $arguments['hidden'];
|
||||
}
|
||||
}
|
||||
}
|
||||
21
vendor/simplesoftwareio/simple-qrcode/src/Facades/QrCode.php
vendored
Normal file
21
vendor/simplesoftwareio/simple-qrcode/src/Facades/QrCode.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace SimpleSoftwareIO\QrCode\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
use SimpleSoftwareIO\QrCode\Generator;
|
||||
|
||||
class QrCode extends Facade
|
||||
{
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
self::clearResolvedInstance(Generator::class);
|
||||
|
||||
return Generator::class;
|
||||
}
|
||||
}
|
||||
578
vendor/simplesoftwareio/simple-qrcode/src/Generator.php
vendored
Normal file
578
vendor/simplesoftwareio/simple-qrcode/src/Generator.php
vendored
Normal file
@@ -0,0 +1,578 @@
|
||||
<?php
|
||||
|
||||
namespace SimpleSoftwareIO\QrCode;
|
||||
|
||||
use BaconQrCode\Common\ErrorCorrectionLevel;
|
||||
use BaconQrCode\Encoder\Encoder;
|
||||
use BaconQrCode\Exception\WriterException;
|
||||
use BaconQrCode\Renderer\Color\Alpha;
|
||||
use BaconQrCode\Renderer\Color\ColorInterface;
|
||||
use BaconQrCode\Renderer\Color\Rgb;
|
||||
use BaconQrCode\Renderer\Eye\EyeInterface;
|
||||
use BaconQrCode\Renderer\Eye\ModuleEye;
|
||||
use BaconQrCode\Renderer\Eye\SimpleCircleEye;
|
||||
use BaconQrCode\Renderer\Eye\SquareEye;
|
||||
use BaconQrCode\Renderer\Image\EpsImageBackEnd;
|
||||
use BaconQrCode\Renderer\Image\ImageBackEndInterface;
|
||||
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
|
||||
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
|
||||
use BaconQrCode\Renderer\ImageRenderer;
|
||||
use BaconQrCode\Renderer\Module\DotsModule;
|
||||
use BaconQrCode\Renderer\Module\ModuleInterface;
|
||||
use BaconQrCode\Renderer\Module\RoundnessModule;
|
||||
use BaconQrCode\Renderer\Module\SquareModule;
|
||||
use BaconQrCode\Renderer\RendererStyle\EyeFill;
|
||||
use BaconQrCode\Renderer\RendererStyle\Fill;
|
||||
use BaconQrCode\Renderer\RendererStyle\Gradient;
|
||||
use BaconQrCode\Renderer\RendererStyle\GradientType;
|
||||
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
||||
use BaconQrCode\Writer;
|
||||
use BadMethodCallException;
|
||||
use InvalidArgumentException;
|
||||
use SimpleSoftwareIO\QrCode\DataTypes\DataTypeInterface;
|
||||
|
||||
class Generator
|
||||
{
|
||||
/**
|
||||
* Holds the selected formatter.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $format = 'svg';
|
||||
|
||||
/**
|
||||
* Holds the size of the QrCode in pixels.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $pixels = 100;
|
||||
|
||||
/**
|
||||
* Holds the margin size of the QrCode.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $margin = 0;
|
||||
|
||||
/**
|
||||
* Holds the selected error correction.
|
||||
* L: 7% loss.
|
||||
* M: 15% loss.
|
||||
* Q: 25% loss.
|
||||
* H: 30% loss.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $errorCorrection = null;
|
||||
|
||||
/**
|
||||
* Holds the selected encoder. Possible values are
|
||||
* ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6,
|
||||
* ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10, ISO-8859-11,
|
||||
* ISO-8859-12, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16,
|
||||
* SHIFT-JIS, WINDOWS-1250, WINDOWS-1251, WINDOWS-1252, WINDOWS-1256,
|
||||
* UTF-16BE, UTF-8, ASCII, GBK, EUC-KR.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $encoding = Encoder::DEFAULT_BYTE_MODE_ECODING;
|
||||
|
||||
/**
|
||||
* The style of the blocks within the QrCode.
|
||||
* Possible values are square, dot, and round.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $style = 'square';
|
||||
|
||||
/**
|
||||
* The size of the selected style between 0 and 1.
|
||||
* This only applies to dot and round.
|
||||
*
|
||||
* @var float|null
|
||||
*/
|
||||
protected $styleSize = null;
|
||||
|
||||
/**
|
||||
* The style to apply to the eye.
|
||||
* Possible values are circle and square.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $eyeStyle = null;
|
||||
|
||||
/**
|
||||
* The foreground color of the QrCode.
|
||||
*
|
||||
* @var ColorInterface|null
|
||||
*/
|
||||
protected $color = null;
|
||||
|
||||
/**
|
||||
* The background color of the QrCode.
|
||||
*
|
||||
* @var ColorInterface|null
|
||||
*/
|
||||
protected $backgroundColor = null;
|
||||
|
||||
/**
|
||||
* An array that holds EyeFills of the color of the eyes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $eyeColors = [];
|
||||
|
||||
/**
|
||||
* The gradient to apply to the QrCode.
|
||||
*
|
||||
* @var Gradient
|
||||
*/
|
||||
protected $gradient;
|
||||
|
||||
/**
|
||||
* Holds an image string that will be merged with the QrCode.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
protected $imageMerge = null;
|
||||
|
||||
/**
|
||||
* The percentage that a merged image should take over the source image.
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $imagePercentage = .2;
|
||||
|
||||
/**
|
||||
* Creates a new datatype object and then generates a QrCode.
|
||||
*
|
||||
* @param $method
|
||||
* @param array $arguments
|
||||
*/
|
||||
public function __call($method, array $arguments)
|
||||
{
|
||||
$dataType = $this->createClass($method);
|
||||
$dataType->create($arguments);
|
||||
|
||||
return $this->generate(strval($dataType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the QrCode.
|
||||
*
|
||||
* @param string $text
|
||||
* @param string|null $filename
|
||||
* @return void|Illuminate\Support\HtmlString|string
|
||||
* @throws WriterException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function generate(string $text, string $filename = null)
|
||||
{
|
||||
$qrCode = $this->getWriter($this->getRenderer())->writeString($text, $this->encoding, $this->errorCorrection);
|
||||
|
||||
if ($this->imageMerge !== null && $this->format === 'png') {
|
||||
$merger = new ImageMerge(new Image($qrCode), new Image($this->imageMerge));
|
||||
$qrCode = $merger->merge($this->imagePercentage);
|
||||
}
|
||||
|
||||
if ($filename) {
|
||||
file_put_contents($filename, $qrCode);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (class_exists(\Illuminate\Support\HtmlString::class)) {
|
||||
return new \Illuminate\Support\HtmlString($qrCode);
|
||||
}
|
||||
|
||||
return $qrCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges an image over the QrCode.
|
||||
*
|
||||
* @param string $filepath
|
||||
* @param float $percentage
|
||||
* @param SimpleSoftwareIO\QrCode\boolean|bool $absolute
|
||||
* @return Generator
|
||||
*/
|
||||
public function merge(string $filepath, float $percentage = .2, bool $absolute = false): self
|
||||
{
|
||||
if (function_exists('base_path') && ! $absolute) {
|
||||
$filepath = base_path().$filepath;
|
||||
}
|
||||
|
||||
$this->imageMerge = file_get_contents($filepath);
|
||||
$this->imagePercentage = $percentage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges an image string with the center of the QrCode.
|
||||
*
|
||||
* @param string $content
|
||||
* @param float $percentage
|
||||
* @return Generator
|
||||
*/
|
||||
public function mergeString(string $content, float $percentage = .2): self
|
||||
{
|
||||
$this->imageMerge = $content;
|
||||
$this->imagePercentage = $percentage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size of the QrCode.
|
||||
*
|
||||
* @param int $pixels
|
||||
* @return Generator
|
||||
*/
|
||||
public function size(int $pixels): self
|
||||
{
|
||||
$this->pixels = $pixels;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the format of the QrCode.
|
||||
*
|
||||
* @param string $format
|
||||
* @return Generator
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function format(string $format): self
|
||||
{
|
||||
if (! in_array($format, ['svg', 'eps', 'png'])) {
|
||||
throw new InvalidArgumentException("\$format must be svg, eps, or png. {$format} is not a valid.");
|
||||
}
|
||||
|
||||
$this->format = $format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the foreground color of the QrCode.
|
||||
*
|
||||
* @param int $red
|
||||
* @param int $green
|
||||
* @param int $blue
|
||||
* @param null|int $alpha
|
||||
* @return Generator
|
||||
*/
|
||||
public function color(int $red, int $green, int $blue, ?int $alpha = null): self
|
||||
{
|
||||
$this->color = $this->createColor($red, $green, $blue, $alpha);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the background color of the QrCode.
|
||||
*
|
||||
* @param int $red
|
||||
* @param int $green
|
||||
* @param int $blue
|
||||
* @param null|int $alpha
|
||||
* @return Generator
|
||||
*/
|
||||
public function backgroundColor(int $red, int $green, int $blue, ?int $alpha = null): self
|
||||
{
|
||||
$this->backgroundColor = $this->createColor($red, $green, $blue, $alpha);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the eye color for the provided eye index.
|
||||
*
|
||||
* @param int $eyeNumber
|
||||
* @param int $innerRed
|
||||
* @param int $innerGreen
|
||||
* @param int $innerBlue
|
||||
* @param int $outterRed
|
||||
* @param int $outterGreen
|
||||
* @param int $outterBlue
|
||||
* @return Generator
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function eyeColor(int $eyeNumber, int $innerRed, int $innerGreen, int $innerBlue, int $outterRed = 0, int $outterGreen = 0, int $outterBlue = 0): self
|
||||
{
|
||||
if ($eyeNumber < 0 || $eyeNumber > 2) {
|
||||
throw new InvalidArgumentException("\$eyeNumber must be 0, 1, or 2. {$eyeNumber} is not valid.");
|
||||
}
|
||||
|
||||
$this->eyeColors[$eyeNumber] = new EyeFill(
|
||||
$this->createColor($innerRed, $innerGreen, $innerBlue),
|
||||
$this->createColor($outterRed, $outterGreen, $outterBlue)
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function gradient($startRed, $startGreen, $startBlue, $endRed, $endGreen, $endBlue, string $type): self
|
||||
{
|
||||
$type = strtoupper($type);
|
||||
$this->gradient = new Gradient(
|
||||
$this->createColor($startRed, $startGreen, $startBlue),
|
||||
$this->createColor($endRed, $endGreen, $endBlue),
|
||||
GradientType::$type()
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the eye style.
|
||||
*
|
||||
* @param string $style
|
||||
* @return Generator
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function eye(string $style): self
|
||||
{
|
||||
if (! in_array($style, ['square', 'circle'])) {
|
||||
throw new InvalidArgumentException("\$style must be square or circle. {$style} is not a valid eye style.");
|
||||
}
|
||||
|
||||
$this->eyeStyle = $style;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the style of the blocks for the QrCode.
|
||||
*
|
||||
* @param string $style
|
||||
* @param float $size
|
||||
* @return Generator
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function style(string $style, float $size = 0.5): self
|
||||
{
|
||||
if (! in_array($style, ['square', 'dot', 'round'])) {
|
||||
throw new InvalidArgumentException("\$style must be square, dot, or round. {$style} is not a valid.");
|
||||
}
|
||||
|
||||
if ($size < 0 || $size >= 1) {
|
||||
throw new InvalidArgumentException("\$size must be between 0 and 1. {$size} is not valid.");
|
||||
}
|
||||
|
||||
$this->style = $style;
|
||||
$this->styleSize = $size;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the encoding for the QrCode.
|
||||
* Possible values are
|
||||
* ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6,
|
||||
* ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10, ISO-8859-11,
|
||||
* ISO-8859-12, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16,
|
||||
* SHIFT-JIS, WINDOWS-1250, WINDOWS-1251, WINDOWS-1252, WINDOWS-1256,
|
||||
* UTF-16BE, UTF-8, ASCII, GBK, EUC-KR.
|
||||
*
|
||||
* @param string $encoding
|
||||
* @return Generator
|
||||
*/
|
||||
public function encoding(string $encoding): self
|
||||
{
|
||||
$this->encoding = strtoupper($encoding);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the error correction for the QrCode.
|
||||
* L: 7% loss.
|
||||
* M: 15% loss.
|
||||
* Q: 25% loss.
|
||||
* H: 30% loss.
|
||||
*
|
||||
* @param string $errorCorrection
|
||||
* @return Generator
|
||||
*/
|
||||
public function errorCorrection(string $errorCorrection): self
|
||||
{
|
||||
$errorCorrection = strtoupper($errorCorrection);
|
||||
$this->errorCorrection = ErrorCorrectionLevel::$errorCorrection();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the margin of the QrCode.
|
||||
*
|
||||
* @param int $margin
|
||||
* @return Generator
|
||||
*/
|
||||
public function margin(int $margin): self
|
||||
{
|
||||
$this->margin = $margin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the Writer.
|
||||
*
|
||||
* @param ImageRenderer $renderer
|
||||
* @return Writer
|
||||
*/
|
||||
public function getWriter(ImageRenderer $renderer): Writer
|
||||
{
|
||||
return new Writer($renderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the Image Renderer.
|
||||
*
|
||||
* @return ImageRenderer
|
||||
*/
|
||||
public function getRenderer(): ImageRenderer
|
||||
{
|
||||
$renderer = new ImageRenderer(
|
||||
$this->getRendererStyle(),
|
||||
$this->getFormatter()
|
||||
);
|
||||
|
||||
return $renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Renderer Style.
|
||||
*
|
||||
* @return RendererStyle
|
||||
*/
|
||||
public function getRendererStyle(): RendererStyle
|
||||
{
|
||||
return new RendererStyle($this->pixels, $this->margin, $this->getModule(), $this->getEye(), $this->getFill());
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the formatter.
|
||||
*
|
||||
* @return ImageBackEndInterface
|
||||
*/
|
||||
public function getFormatter(): ImageBackEndInterface
|
||||
{
|
||||
if ($this->format === 'png') {
|
||||
return new ImagickImageBackEnd('png');
|
||||
}
|
||||
|
||||
if ($this->format === 'eps') {
|
||||
return new EpsImageBackEnd;
|
||||
}
|
||||
|
||||
return new SvgImageBackEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the module.
|
||||
*
|
||||
* @return ModuleInterface
|
||||
*/
|
||||
public function getModule(): ModuleInterface
|
||||
{
|
||||
if ($this->style === 'dot') {
|
||||
return new DotsModule($this->styleSize);
|
||||
}
|
||||
|
||||
if ($this->style === 'round') {
|
||||
return new RoundnessModule($this->styleSize);
|
||||
}
|
||||
|
||||
return SquareModule::instance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the eye style.
|
||||
*
|
||||
* @return EyeInterface
|
||||
*/
|
||||
public function getEye(): EyeInterface
|
||||
{
|
||||
if ($this->eyeStyle === 'square') {
|
||||
return SquareEye::instance();
|
||||
}
|
||||
|
||||
if ($this->eyeStyle === 'circle') {
|
||||
return SimpleCircleEye::instance();
|
||||
}
|
||||
|
||||
return new ModuleEye($this->getModule());
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the color fill.
|
||||
*
|
||||
* @return Fill
|
||||
*/
|
||||
public function getFill(): Fill
|
||||
{
|
||||
$foregroundColor = $this->color ?? new Rgb(0, 0, 0);
|
||||
$backgroundColor = $this->backgroundColor ?? new Rgb(255, 255, 255);
|
||||
$eye0 = $this->eyeColors[0] ?? EyeFill::inherit();
|
||||
$eye1 = $this->eyeColors[1] ?? EyeFill::inherit();
|
||||
$eye2 = $this->eyeColors[2] ?? EyeFill::inherit();
|
||||
|
||||
if ($this->gradient) {
|
||||
return Fill::withForegroundGradient($backgroundColor, $this->gradient, $eye0, $eye1, $eye2);
|
||||
}
|
||||
|
||||
return Fill::withForegroundColor($backgroundColor, $foregroundColor, $eye0, $eye1, $eye2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a RGB or Alpha channel color.
|
||||
* @param int $red
|
||||
* @param int $green
|
||||
* @param int $blue
|
||||
* @param null|int $alpha
|
||||
* @return ColorInterface
|
||||
*/
|
||||
public function createColor(int $red, int $green, int $blue, ?int $alpha = null): ColorInterface
|
||||
{
|
||||
if (is_null($alpha)) {
|
||||
return new Rgb($red, $green, $blue);
|
||||
}
|
||||
|
||||
return new Alpha($alpha, new Rgb($red, $green, $blue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new DataType class dynamically.
|
||||
*
|
||||
* @param string $method
|
||||
* @return DataTypeInterface
|
||||
*/
|
||||
protected function createClass(string $method): DataTypeInterface
|
||||
{
|
||||
$class = $this->formatClass($method);
|
||||
|
||||
if (! class_exists($class)) {
|
||||
throw new BadMethodCallException();
|
||||
}
|
||||
|
||||
return new $class();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the method name correctly.
|
||||
*
|
||||
* @param $method
|
||||
* @return string
|
||||
*/
|
||||
protected function formatClass(string $method): string
|
||||
{
|
||||
$method = ucfirst($method);
|
||||
|
||||
$class = "SimpleSoftwareIO\QrCode\DataTypes\\".$method;
|
||||
|
||||
return $class;
|
||||
}
|
||||
}
|
||||
63
vendor/simplesoftwareio/simple-qrcode/src/Image.php
vendored
Normal file
63
vendor/simplesoftwareio/simple-qrcode/src/Image.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace SimpleSoftwareIO\QrCode;
|
||||
|
||||
class Image
|
||||
{
|
||||
/**
|
||||
* Holds the image resource.
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
protected $image;
|
||||
|
||||
/**
|
||||
* Creates a new Image object.
|
||||
*
|
||||
* @param $image string An image string
|
||||
*/
|
||||
public function __construct($image)
|
||||
{
|
||||
$this->image = imagecreatefromstring($image);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the width of an image
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return imagesx($this->image);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the height of an image
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return imagesy($this->image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageResource()
|
||||
{
|
||||
return $this->image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the image string.
|
||||
*
|
||||
* @param resource $image
|
||||
*/
|
||||
public function setImageResource($image)
|
||||
{
|
||||
$this->image = $image;
|
||||
}
|
||||
}
|
||||
204
vendor/simplesoftwareio/simple-qrcode/src/ImageMerge.php
vendored
Normal file
204
vendor/simplesoftwareio/simple-qrcode/src/ImageMerge.php
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace SimpleSoftwareIO\QrCode;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
class ImageMerge
|
||||
{
|
||||
/**
|
||||
* Holds the QrCode image.
|
||||
*
|
||||
* @var Image
|
||||
*/
|
||||
protected $sourceImage;
|
||||
|
||||
/**
|
||||
* Holds the merging image.
|
||||
*
|
||||
* @var Image
|
||||
*/
|
||||
protected $mergeImage;
|
||||
|
||||
/**
|
||||
* The height of the source image.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $sourceImageHeight;
|
||||
|
||||
/**
|
||||
* The width of the source image.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $sourceImageWidth;
|
||||
|
||||
/**
|
||||
* The height of the merge image.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $mergeImageHeight;
|
||||
|
||||
/**
|
||||
* The width of the merge image.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $mergeImageWidth;
|
||||
|
||||
/**
|
||||
* Holds the radio of the merging image.
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $mergeRatio;
|
||||
|
||||
/**
|
||||
* The height of the merge image after it is merged.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $postMergeImageHeight;
|
||||
|
||||
/**
|
||||
* The width of the merge image after it is merged.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $postMergeImageWidth;
|
||||
|
||||
/**
|
||||
* The position that the merge image is placed on top of the source image.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $centerY;
|
||||
|
||||
/**
|
||||
* The position that the merge image is placed on top of the source image.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $centerX;
|
||||
|
||||
/**
|
||||
* Creates a new ImageMerge object.
|
||||
*
|
||||
* @param $sourceImage Image The image that will be merged over.
|
||||
* @param $mergeImage Image The image that will be used to merge with $sourceImage
|
||||
*/
|
||||
public function __construct(Image $sourceImage, Image $mergeImage)
|
||||
{
|
||||
$this->sourceImage = $sourceImage;
|
||||
$this->mergeImage = $mergeImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an QrCode that has been merge with another image.
|
||||
* This is usually used with logos to imprint a logo into a QrCode.
|
||||
*
|
||||
* @param $percentage float The percentage of size relative to the entire QR of the merged image
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function merge($percentage)
|
||||
{
|
||||
$this->setProperties($percentage);
|
||||
|
||||
$img = imagecreatetruecolor($this->sourceImage->getWidth(), $this->sourceImage->getHeight());
|
||||
imagealphablending($img, true);
|
||||
$transparent = imagecolorallocatealpha($img, 0, 0, 0, 127);
|
||||
imagefill($img, 0, 0, $transparent);
|
||||
|
||||
imagecopy(
|
||||
$img,
|
||||
$this->sourceImage->getImageResource(),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
$this->sourceImage->getWidth(),
|
||||
$this->sourceImage->getHeight()
|
||||
);
|
||||
|
||||
imagecopyresampled(
|
||||
$img,
|
||||
$this->mergeImage->getImageResource(),
|
||||
$this->centerX,
|
||||
$this->centerY,
|
||||
0,
|
||||
0,
|
||||
$this->postMergeImageWidth,
|
||||
$this->postMergeImageHeight,
|
||||
$this->mergeImageWidth,
|
||||
$this->mergeImageHeight
|
||||
);
|
||||
|
||||
$this->sourceImage->setImageResource($img);
|
||||
|
||||
return $this->createImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a PNG Image.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createImage()
|
||||
{
|
||||
ob_start();
|
||||
imagepng($this->sourceImage->getImageResource());
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the objects properties.
|
||||
*
|
||||
* @param $percentage float The percentage that the merge image should take up.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setProperties($percentage)
|
||||
{
|
||||
if ($percentage > 1) {
|
||||
throw new InvalidArgumentException('$percentage must be less than 1');
|
||||
}
|
||||
|
||||
$this->sourceImageHeight = $this->sourceImage->getHeight();
|
||||
$this->sourceImageWidth = $this->sourceImage->getWidth();
|
||||
|
||||
$this->mergeImageHeight = $this->mergeImage->getHeight();
|
||||
$this->mergeImageWidth = $this->mergeImage->getWidth();
|
||||
|
||||
$this->calculateOverlap($percentage);
|
||||
$this->calculateCenter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the center of the source Image using the Merge image.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function calculateCenter()
|
||||
{
|
||||
$this->centerX = intval(($this->sourceImageWidth / 2) - ($this->postMergeImageWidth / 2));
|
||||
$this->centerY = intval(($this->sourceImageHeight / 2) - ($this->postMergeImageHeight / 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the width of the merge image being placed on the source image.
|
||||
*
|
||||
* @param float $percentage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function calculateOverlap($percentage)
|
||||
{
|
||||
$this->mergeRatio = round($this->mergeImageWidth / $this->mergeImageHeight, 2);
|
||||
$this->postMergeImageWidth = intval($this->sourceImageWidth * $percentage);
|
||||
$this->postMergeImageHeight = intval($this->postMergeImageWidth / $this->mergeRatio);
|
||||
}
|
||||
}
|
||||
28
vendor/simplesoftwareio/simple-qrcode/src/QrCodeServiceProvider.php
vendored
Normal file
28
vendor/simplesoftwareio/simple-qrcode/src/QrCodeServiceProvider.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace SimpleSoftwareIO\QrCode;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class QrCodeServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->bind('qrcode', function () {
|
||||
return new Generator();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [Generator::class];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user