From 7a40775be51e490cd53514ff763467a3663bc492 Mon Sep 17 00:00:00 2001 From: Koldo Picaza <1093654+kpicaza@users.noreply.github.com> Date: Sat, 2 Oct 2021 13:59:08 +0200 Subject: [PATCH] [#15] add ability to collect events in Feature write model --- grumphp.yml | 2 -- src/Write/Feature.php | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/grumphp.yml b/grumphp.yml index 22d9057..0cda4f7 100644 --- a/grumphp.yml +++ b/grumphp.yml @@ -1,6 +1,4 @@ grumphp: - git_hook_variables: - EXEC_GRUMPHP_COMMAND: 'docker run -e "TERM=xterm-256color" --tty=true --rm -v $PWD:/code:cached pheature/pheature-php-dev:latest' hooks_dir: . hooks_preset: local tasks: diff --git a/src/Write/Feature.php b/src/Write/Feature.php index 2e73fc3..fe6f2e1 100644 --- a/src/Write/Feature.php +++ b/src/Write/Feature.php @@ -13,10 +13,10 @@ final class Feature implements JsonSerializable { private FeatureId $featureId; private bool $enabled; - /** - * @var Strategy[] - */ + /** @var Strategy[] */ private array $strategies = []; + /** @var array */ + private array $events = []; /** * Feature constructor. @@ -34,6 +34,17 @@ public function __construct(FeatureId $featureId, bool $enabled, array $strategi } } + /** + * @return object[] + */ + public function release(): array + { + $events = $this->events; + $this->events = []; + + return $events; + } + public static function withId(FeatureId $featureId): self { return new self($featureId, false);