Skip to content

Commit 36e47d9

Browse files
committed
feat(sanitizer): refactor Sanitize attribute to extend BaseProcessorAttribute
- Refactored the Sanitize attribute class to extend the BaseProcessorAttribute for improved code reusability and maintainability. - Removed redundant methods that are now inherited from the base class.
1 parent 2bd479a commit 36e47d9

2 files changed

Lines changed: 7 additions & 26 deletions

File tree

composer.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Attribute/Sanitize.php

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,9 @@
22

33
namespace KaririCode\Sanitizer\Attribute;
44

5-
use KaririCode\Contract\Processor\Attribute\CustomizableMessageAttribute;
6-
use KaririCode\Contract\Processor\Attribute\ProcessableAttribute;
5+
use KaririCode\Contract\Processor\Attribute\BaseProcessorAttribute;
76

87
#[\Attribute(\Attribute::TARGET_PROPERTY)]
9-
final class Sanitize implements ProcessableAttribute, CustomizableMessageAttribute
8+
final class Sanitize extends BaseProcessorAttribute
109
{
11-
private readonly array $processors;
12-
private readonly array $messages;
13-
14-
public function __construct(array $processors, ?array $messages = null)
15-
{
16-
$this->processors = array_filter($processors, fn ($v) => !is_null($v) && false !== $v);
17-
$this->messages = $messages ?? [];
18-
}
19-
20-
public function getProcessors(): array
21-
{
22-
return $this->processors;
23-
}
24-
25-
public function getMessage($processorName): ?string
26-
{
27-
return $this->messages[$processorName] ?? null;
28-
}
2910
}

0 commit comments

Comments
 (0)