Мелкофиксы по кодстайлу

This commit is contained in:
2021-12-12 14:50:29 +08:00
parent 464a8f0706
commit c7d07a18f1
21 changed files with 178 additions and 75 deletions

View File

@@ -16,8 +16,12 @@ use AtolOnline\Exceptions\{
EmptyAddUserPropNameException,
EmptyAddUserPropValueException,
TooLongAddUserPropNameException,
TooLongAddUserPropValueException};
use JetBrains\PhpStorm\Pure;
TooLongAddUserPropValueException
};
use JetBrains\PhpStorm\{
ArrayShape,
Pure
};
/**
* Класс, описывающий дополнительный реквизит пользователя
@@ -117,6 +121,7 @@ final class AdditionalUserProps extends Entity
* @inheritDoc
*/
#[Pure]
#[ArrayShape(['name' => 'string', 'value' => 'null|string'])]
public function jsonSerialize(): array
{
return [

View File

@@ -11,8 +11,14 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\{Constants\Constraints, Enums\SnoTypes, Traits\HasEmail, Traits\HasInn};
use AtolOnline\Exceptions\{InvalidEmailException,
use AtolOnline\{
Constants\Constraints,
Enums\SnoTypes,
Traits\HasEmail,
Traits\HasInn
};
use AtolOnline\Exceptions\{
InvalidEmailException,
InvalidEnumValueException,
InvalidInnLengthException,
InvalidPaymentAddressException,

View File

@@ -9,9 +9,15 @@
namespace AtolOnline\Entities;
use AtolOnline\Collections\{Payments, Vats};
use AtolOnline\Constants\Constraints;
use AtolOnline\Exceptions\{InvalidEntityInCollectionException, TooLongCashierException};
use AtolOnline\{
Constants\Constraints,
Payments,
Vats
};
use AtolOnline\Exceptions\{
InvalidEntityInCollectionException,
TooLongCashierException
};
use Exception;
use JetBrains\PhpStorm\ArrayShape;
@@ -28,8 +34,8 @@ class Correction extends Entity
protected Company $company;
/**
* @todo вынести в трейт?
* @var string|null ФИО кассира
* @todo вынести в трейт
*/
protected ?string $cashier = null;
@@ -195,11 +201,11 @@ class Correction extends Entity
* @throws InvalidEntityInCollectionException
*/
#[ArrayShape([
'company' => "\AtolOnline\Entities\Company",
'correction_info' => "\AtolOnline\Entities\CorrectionInfo",
'payments' => "array",
'vats' => "\AtolOnline\Collections\Vats|null",
'cashier' => "null|string"
'company' => '\AtolOnline\Entities\Company',
'correction_info' => '\AtolOnline\Entities\CorrectionInfo',
'payments' => 'array',
'vats' => '\AtolOnline\Collections\Vats|null',
'cashier' => 'null|string',
])]
public function jsonSerialize(): array
{

View File

@@ -7,7 +7,9 @@
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
*/
declare(strict_types=1);
/** @noinspection PhpMultipleClassDeclarationsInspection */
declare(strict_types = 1);
namespace AtolOnline\Entities;

View File

@@ -556,8 +556,8 @@ final class Item extends Entity
if (is_string($declaration_number)) {
$declaration_number = trim($declaration_number);
if (
mb_strlen($declaration_number) < Constraints::MIN_LENGTH_DECLARATION_NUMBER ||
mb_strlen($declaration_number) > Constraints::MAX_LENGTH_DECLARATION_NUMBER
mb_strlen($declaration_number) < Constraints::MIN_LENGTH_DECLARATION_NUMBER
|| mb_strlen($declaration_number) > Constraints::MAX_LENGTH_DECLARATION_NUMBER
) {
throw new InvalidDeclarationNumberException($declaration_number);
}

View File

@@ -11,10 +11,19 @@ declare(strict_types = 1);
namespace AtolOnline\Entities;
use AtolOnline\Constants\Constraints;
use AtolOnline\Enums\PaymentTypes;
use AtolOnline\Exceptions\{InvalidEnumValueException, NegativePaymentSumException, TooHighPaymentSumException,};
use JetBrains\PhpStorm\{ArrayShape, Pure};
use AtolOnline\{
Constants\Constraints,
Enums\PaymentTypes,
};
use AtolOnline\Exceptions\{
InvalidEnumValueException,
NegativePaymentSumException,
TooHighPaymentSumException,
};
use JetBrains\PhpStorm\{
ArrayShape,
Pure
};
/**
* Класс, описывающий оплату

View File

@@ -34,8 +34,8 @@ final class Receipt extends Entity
protected Client $client;
/**
* @todo вынести в трейт?
* @var Company Продавец
* @todo вынести в трейт
*/
protected Company $company;
@@ -55,8 +55,8 @@ final class Receipt extends Entity
protected Items $items;
/**
* @todo вынести в трейт?
* @var Payments Коллекция оплат
* @todo вынести в трейт
*/
protected Payments $payments;
@@ -71,8 +71,8 @@ final class Receipt extends Entity
protected float $total = 0;
/**
* @todo вынести в трейт?
* @var string|null ФИО кассира
* @todo вынести в трейт
*/
protected ?string $cashier = null;
@@ -204,10 +204,9 @@ final class Receipt extends Entity
*
* @param Items $items
* @return $this
* @throws EmptyItemsException
* @throws InvalidEntityInCollectionException
* @throws Exception
* @todo исключение при пустой коллекции
* @throws EmptyItemsException
*/
public function setItems(Items $items): self
{

View File

@@ -106,15 +106,17 @@ final class Vat extends Entity
#[Pure]
public function getCalculated(): float
{
return Helpers::toRub(match ($this->getType()) {
VatTypes::VAT10 => Helpers::toKop($this->sum) * 10 / 100,
VatTypes::VAT18 => Helpers::toKop($this->sum) * 18 / 100,
VatTypes::VAT20 => Helpers::toKop($this->sum) * 20 / 100,
VatTypes::VAT110 => Helpers::toKop($this->sum) * 10 / 110,
VatTypes::VAT118 => Helpers::toKop($this->sum) * 18 / 118,
VatTypes::VAT120 => Helpers::toKop($this->sum) * 20 / 120,
default => 0,
});
return Helpers::toRub(
match ($this->getType()) {
VatTypes::VAT10 => Helpers::toKop($this->sum) * 10 / 100,
VatTypes::VAT18 => Helpers::toKop($this->sum) * 18 / 100,
VatTypes::VAT20 => Helpers::toKop($this->sum) * 20 / 100,
VatTypes::VAT110 => Helpers::toKop($this->sum) * 10 / 110,
VatTypes::VAT118 => Helpers::toKop($this->sum) * 18 / 118,
VatTypes::VAT120 => Helpers::toKop($this->sum) * 20 / 120,
default => 0,
}
);
}
/**