32 lines
744 B
PHP
32 lines
744 B
PHP
<?php
|
|
|
|
class DataTransferRegistry
|
|
{
|
|
private bool $allowed;
|
|
private array $entries;
|
|
|
|
public function __construct(bool $allowed, array $entries = [])
|
|
{
|
|
$this->allowed = $allowed;
|
|
$this->entries = $entries;
|
|
}
|
|
|
|
public function isAllowed(string $vendorId, string $messageId = ''): bool
|
|
{
|
|
if (!$this->allowed) {
|
|
return false;
|
|
}
|
|
if (empty($this->entries)) {
|
|
return true;
|
|
}
|
|
foreach ($this->entries as $entry) {
|
|
if (($entry['vendorId'] ?? '') === $vendorId && (($entry['messageId'] ?? '') === '' || ($entry['messageId'] ?? '') === $messageId)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
?>
|