feat: better data wf
This commit is contained in:
115
src/Entity/Input/QRCode/QRCode.php
Normal file
115
src/Entity/Input/QRCode/QRCode.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity\Input\QRCode;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* QRCode description
|
||||
*/
|
||||
class QRCode
|
||||
{
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Iban(
|
||||
message: 'messages.not_a_iban_number',
|
||||
)]
|
||||
private ?string $iban;
|
||||
#[Assert\NotBlank(message: 'messages.fill_value')]
|
||||
#[Assert\GreaterThanOrEqual(
|
||||
'today', message: 'messages.invalid_date'
|
||||
)]
|
||||
private ?\DateTime $dueDate;
|
||||
#[Assert\NotBlank(message: 'messages.fill_value')]
|
||||
private ?string $message;
|
||||
|
||||
#[Assert\Valid]
|
||||
#[Assert\NotBlank]
|
||||
private ?QRCodeMoney $money;
|
||||
#[Assert\Valid]
|
||||
#[Assert\NotBlank]
|
||||
private ?QRCodePaymentIdentification $paymentIdentification;
|
||||
#[Assert\Valid]
|
||||
#[Assert\NotBlank]
|
||||
private readonly QRCodeQROptions $codeQROptions;
|
||||
|
||||
/**
|
||||
* @param QRCodeQROptions $codeQROptions
|
||||
* @param string|null $iban
|
||||
* @param \DateTime|null $dueDate
|
||||
* @param string|null $message
|
||||
* @param QRCodeMoney|null $money
|
||||
*/
|
||||
public function __construct(
|
||||
QRCodeQROptions $codeQROptions,
|
||||
?string $iban = null,
|
||||
?\DateTime $dueDate = null,
|
||||
?string $message = null,
|
||||
?QRCodeMoney $money = null)
|
||||
{
|
||||
$this->iban = $iban;
|
||||
$this->dueDate = $dueDate;
|
||||
$this->message = $message;
|
||||
$this->money = $money;
|
||||
$this->codeQROptions = $codeQROptions;
|
||||
}
|
||||
|
||||
public function getIban(): ?string
|
||||
{
|
||||
return $this->iban;
|
||||
}
|
||||
|
||||
public function setIban(?string $iban): void
|
||||
{
|
||||
$this->iban = $iban;
|
||||
}
|
||||
|
||||
public function getDueDate(): ?\DateTime
|
||||
{
|
||||
return $this->dueDate;
|
||||
}
|
||||
|
||||
public function setDueDate(?\DateTime $dueDate): void
|
||||
{
|
||||
$this->dueDate = $dueDate;
|
||||
}
|
||||
|
||||
public function getMessage(): ?string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function setMessage(?string $message): void
|
||||
{
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
public function getMoney(): ?QRCodeMoney
|
||||
{
|
||||
return $this->money;
|
||||
}
|
||||
|
||||
public function setMoney(?QRCodeMoney $money): void
|
||||
{
|
||||
$this->money = $money;
|
||||
}
|
||||
|
||||
public function getCodeQROptions(): ?QRCodeQROptions
|
||||
{
|
||||
return $this->codeQROptions;
|
||||
}
|
||||
|
||||
|
||||
public function getPaymentIdentification(): ?QRCodePaymentIdentification
|
||||
{
|
||||
return $this->paymentIdentification;
|
||||
}
|
||||
|
||||
public function setPaymentIdentification(?QRCodePaymentIdentification $paymentIdentification): void
|
||||
{
|
||||
$this->paymentIdentification = $paymentIdentification;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
59
src/Entity/Input/QRCode/QRCodeMoney.php
Normal file
59
src/Entity/Input/QRCode/QRCodeMoney.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity\Input\QRCode;
|
||||
|
||||
use App\Validator\Currency;
|
||||
use App\Validator\Money;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Money type for QR code
|
||||
*/
|
||||
class QRCodeMoney
|
||||
{
|
||||
#[Assert\Positive(
|
||||
message: 'messages.not_valid_amount',
|
||||
)]
|
||||
#[Assert\NotBlank(message: 'messages.fill_value')]
|
||||
#[Money(message: 'messages.not_valid_amount')]
|
||||
private ?string $amount;
|
||||
|
||||
// TODO: getCurrencies validation
|
||||
#[Assert\NotBlank(message: 'messages.fill_value')]
|
||||
#[Currency(message: 'messages.not_currency')]
|
||||
private ?string $currency;
|
||||
|
||||
/**
|
||||
* @param string|null $amount
|
||||
* @param string|null $currency
|
||||
*/
|
||||
public function __construct(?string $amount = null, ?string $currency = null)
|
||||
{
|
||||
$this->amount = $amount;
|
||||
$this->currency = $currency;
|
||||
}
|
||||
|
||||
|
||||
public function getAmount(): ?string
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
public function setAmount(?string $amount): void
|
||||
{
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
public function getCurrency(): ?string
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
public function setCurrency(?string $currency): void
|
||||
{
|
||||
$this->currency = $currency;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
58
src/Entity/Input/QRCode/QRCodePaymentIdentification.php
Normal file
58
src/Entity/Input/QRCode/QRCodePaymentIdentification.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity\Input\QRCode;
|
||||
|
||||
use App\Validator\BankPaymentIdentificationNumber;
|
||||
|
||||
/**
|
||||
* Payment identification for QR code
|
||||
*/
|
||||
class QRCodePaymentIdentification {
|
||||
#[BankPaymentIdentificationNumber(
|
||||
message: 'messages.not_variable_symbol',
|
||||
)]
|
||||
private ?string $variableSymbol = null;
|
||||
|
||||
#[BankPaymentIdentificationNumber(
|
||||
message: 'messages.not_specific_symbol',
|
||||
)]
|
||||
private ?string $specificSymbol = null;
|
||||
|
||||
#[BankPaymentIdentificationNumber(
|
||||
message: 'messages.not_constant_symbol',
|
||||
)] // https://www.hyponamiru.cz/en/glossary/constant-symbol/
|
||||
private ?string $constantSymbol = null;
|
||||
|
||||
public function getVariableSymbol(): ?string
|
||||
{
|
||||
return $this->variableSymbol;
|
||||
}
|
||||
|
||||
public function setVariableSymbol(?string $variableSymbol): void
|
||||
{
|
||||
$this->variableSymbol = $variableSymbol;
|
||||
}
|
||||
|
||||
public function getSpecificSymbol(): ?string
|
||||
{
|
||||
return $this->specificSymbol;
|
||||
}
|
||||
|
||||
public function setSpecificSymbol(?string $specificSymbol): void
|
||||
{
|
||||
$this->specificSymbol = $specificSymbol;
|
||||
}
|
||||
|
||||
public function getConstantSymbol(): ?string
|
||||
{
|
||||
return $this->constantSymbol;
|
||||
}
|
||||
|
||||
public function setConstantSymbol(?string $constantSymbol): void
|
||||
{
|
||||
$this->constantSymbol = $constantSymbol;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
43
src/Entity/Input/QRCode/QRCodeQROptions.php
Normal file
43
src/Entity/Input/QRCode/QRCodeQROptions.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity\Input\QRCode;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Options for generating QR code
|
||||
*/
|
||||
readonly class QRCodeQROptions {
|
||||
#[Assert\Positive(
|
||||
message: 'messages.scale_must_be_positive',
|
||||
)]
|
||||
#[Assert\NotBlank(message: 'messages.fill_value')]
|
||||
private int $scale;
|
||||
|
||||
#[Assert\PositiveOrZero(
|
||||
message: 'messages.margin_must_be_positive',
|
||||
)]
|
||||
#[Assert\NotBlank(message: 'messages.fill_value')]
|
||||
private int $margin;
|
||||
|
||||
/**
|
||||
* @param int $scale scaling of png image (2 = 1px is mapped onto 2px, 3 = 1px onto 3px etc.)
|
||||
* @param int $margin white borders of png image in pixels
|
||||
*/
|
||||
public function __construct(int $scale, int $margin)
|
||||
{
|
||||
$this->scale = $scale;
|
||||
$this->margin = $margin;
|
||||
}
|
||||
|
||||
public function getScale(): int
|
||||
{
|
||||
return $this->scale;
|
||||
}
|
||||
|
||||
public function getMargin(): int
|
||||
{
|
||||
return $this->margin;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user