You've already forked wc-licensed-product-client
- Add JSON encoding error handling in ResponseSignature to prevent silent failures - Sanitize exception messages to prevent information disclosure - Fix header normalization to treat empty values as null - Add SSRF protection with URL validation and private IP blocking - Replace custom key derivation with RFC 5869 compliant hash_hkdf() - Add input validation in DTO fromArray() methods - Add DateTime exception handling in DTOs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
30 lines
783 B
PHP
30 lines
783 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Magdev\WcLicensedProductClient\Dto;
|
|
|
|
final readonly class ActivationResult
|
|
{
|
|
public function __construct(
|
|
public bool $success,
|
|
public string $message,
|
|
) {
|
|
}
|
|
|
|
public static function fromArray(array $data): self
|
|
{
|
|
if (!isset($data['success']) || !is_bool($data['success'])) {
|
|
throw new \InvalidArgumentException('Invalid response: missing or invalid success field');
|
|
}
|
|
if (!isset($data['message']) || !is_string($data['message'])) {
|
|
throw new \InvalidArgumentException('Invalid response: missing or invalid message field');
|
|
}
|
|
|
|
return new self(
|
|
success: $data['success'],
|
|
message: $data['message'],
|
|
);
|
|
}
|
|
}
|