Skip to content

Commit

Permalink
attributes add options
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Jan 30, 2023
1 parent 07e2fcf commit 71d7649
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 78 deletions.
37 changes: 32 additions & 5 deletions src/AttributeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,25 @@ class AttributeHandler
/**
* AttributeHandler constructor.
*
* @param callable $handler
* @param Reflector $reflector
* @param object|null $object
* @param AttributesResolver $resolver
* @param callable $handler
* @param Reflector $reflector
* @param object|null $object
* @param AttributesResolver $resolver
* @param array $options
*/
public function __construct(
callable $handler,
protected Reflector $reflector,
protected ?object $object,
protected AttributesResolver $resolver
protected AttributesResolver $resolver,
protected array $options = [],
) {
$this->handler = $handler;

$this->options = array_merge(
$this->resolver->getOptions(),
$this->options
);
}

public function __invoke(&...$args): mixed
Expand Down Expand Up @@ -85,4 +92,24 @@ public function getObject(): mixed
{
return $this->object;
}

/**
* @return array
*/
public function &getOptions(): array
{
return $this->options;
}

/**
* @param array $options
*
* @return static Return self to support chaining.
*/
public function setOptions(array $options): static
{
$this->options = $options;

return $this;
}
}
Loading

0 comments on commit 71d7649

Please sign in to comment.