refactor: DTO and VO updates
This commit is contained in:
parent
fa5e7b29ee
commit
a3f444a670
6 changed files with 12 additions and 7 deletions
|
|
@ -5,6 +5,8 @@ declare(strict_types=1);
|
|||
namespace Uwil\ArcadiaApiPhpClient\Lib;
|
||||
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use Uwil\ArcadiaApiPhpClient\Auth\ClientIdentifier;
|
||||
use Uwil\ArcadiaApiPhpClient\Auth\ClientSecret;
|
||||
|
||||
readonly class ApiConfig
|
||||
{
|
||||
|
|
@ -12,13 +14,16 @@ readonly class ApiConfig
|
|||
#[\SensitiveParameter]
|
||||
public readonly UriInterface $endpoint,
|
||||
#[\SensitiveParameter]
|
||||
public readonly string $apiKey,
|
||||
public readonly ClientIdentifier $apiKey,
|
||||
#[\SensitiveParameter]
|
||||
public readonly string $secret,
|
||||
public readonly ClientSecret $secret,
|
||||
public readonly float $curlTimeOut = 20.0,
|
||||
public readonly int $maxRetries = 0,
|
||||
public readonly int $retryDelayMs = 500,
|
||||
) {
|
||||
if ($curlTimeOut < 0) {
|
||||
throw new \InvalidArgumentException('curlTimeOut must be non-negative');
|
||||
}
|
||||
if ($maxRetries < 0) {
|
||||
throw new \InvalidArgumentException('maxRetries must be non-negative');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ final readonly class Brand implements Dto
|
|||
public readonly BrandCode $code,
|
||||
public readonly string $label
|
||||
) {
|
||||
if (empty(trim($label))) {
|
||||
if (empty(mb_trim($label))) {
|
||||
throw new DomainException(
|
||||
"Invalid label '{$label}' should not be empty"
|
||||
);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ final readonly class Allergen implements Dto
|
|||
);
|
||||
}
|
||||
|
||||
if (empty(trim($label))) {
|
||||
if (empty(mb_trim($label))) {
|
||||
throw new DomainException(
|
||||
"Invalid label '{$label}' should not be empty"
|
||||
);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ final readonly class Ingredients implements Dto
|
|||
);
|
||||
}
|
||||
|
||||
if (empty(trim($line))) {
|
||||
if (empty(mb_trim($line))) {
|
||||
throw new DomainException(
|
||||
"Invalid ingredient at group '{$key}', index '{$i}': string should not be empty"
|
||||
);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ final readonly class StorageCondition implements Dto
|
|||
public function __construct(
|
||||
public readonly string $instructions,
|
||||
) {
|
||||
if (empty(trim($this->instructions))) {
|
||||
if (empty(mb_trim($this->instructions))) {
|
||||
throw new DomainException(
|
||||
'Invalid instructions: must not be empty'
|
||||
);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ final readonly class AbstractSorter
|
|||
public string $sortBy,
|
||||
public Direction $direction
|
||||
) {
|
||||
if (empty(trim($sortBy))) {
|
||||
if (empty(mb_trim($sortBy))) {
|
||||
throw new DomainException('Sort by cannot be empty');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue