refactor(01-tech-debt): extract AllegroTokenManager and StringHelper
Phase 1 complete (2/2 plans): - Plan 01-01: Extract AllegroTokenManager — OAuth token logic centralized from 4 classes into dedicated manager class - Plan 01-02: Extract StringHelper — nullableString/normalizeDateTime/ normalizeColorHex extracted from 15+ classes into App\Core\Support\StringHelper; removed 19 duplicate private methods Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Settings;
|
||||
|
||||
use App\Core\Support\StringHelper;
|
||||
use PDO;
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
@@ -98,15 +99,15 @@ final class InpostIntegrationRepository
|
||||
WHERE id = 1'
|
||||
);
|
||||
$statement->execute([
|
||||
'api_token_encrypted' => $this->nullableString((string) $nextEncrypted),
|
||||
'organization_id' => $this->nullableString(trim((string) ($payload['organization_id'] ?? ''))),
|
||||
'api_token_encrypted' => StringHelper::nullableString((string) $nextEncrypted),
|
||||
'organization_id' => StringHelper::nullableString(trim((string) ($payload['organization_id'] ?? ''))),
|
||||
'environment' => in_array($payload['environment'] ?? '', ['sandbox', 'production'], true)
|
||||
? $payload['environment']
|
||||
: 'sandbox',
|
||||
'default_dispatch_method' => in_array($payload['default_dispatch_method'] ?? '', ['pop', 'parcel_locker', 'courier'], true)
|
||||
? $payload['default_dispatch_method']
|
||||
: 'pop',
|
||||
'default_dispatch_point' => $this->nullableString(trim((string) ($payload['default_dispatch_point'] ?? ''))),
|
||||
'default_dispatch_point' => StringHelper::nullableString(trim((string) ($payload['default_dispatch_point'] ?? ''))),
|
||||
'default_insurance' => ($payload['default_insurance'] ?? '') !== ''
|
||||
? (float) $payload['default_insurance']
|
||||
: null,
|
||||
@@ -215,9 +216,4 @@ final class InpostIntegrationRepository
|
||||
);
|
||||
}
|
||||
|
||||
private function nullableString(string $value): ?string
|
||||
{
|
||||
$trimmed = trim($value);
|
||||
return $trimmed === '' ? null : $trimmed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user