From 501b0a3ecb8e64285f7973166635e0eadb25033a Mon Sep 17 00:00:00 2001 From: Tom Wright Date: Tue, 14 Nov 2023 08:44:26 +0000 Subject: [PATCH] Renamed enums to PascalCase Signed-off-by: Tom Wright --- CHANGELOG.md | 2 ++ composer.json | 2 +- src/Stash/Item.php | 22 +++++++++++----------- src/Stash/PileUpPolicy.php | 8 ++++---- src/Stash/Store/Generic.php | 10 +++++----- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15deea3..f7808c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +* Renamed enums to PascalCase + ## v0.2.1 (2023-11-09) * Improved selection of drivers to purge diff --git a/composer.json b/composer.json index 2be1fde..41cb7c1 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,7 @@ }, "extra": { "branch-alias": { - "dev-develop": "0.2.x-dev" + "dev-develop": "0.3.x-dev" } } } diff --git a/src/Stash/Item.php b/src/Stash/Item.php index b986195..5f5e677 100644 --- a/src/Stash/Item.php +++ b/src/Stash/Item.php @@ -239,7 +239,7 @@ public function getTimeRemaining(): ?CarbonInterval */ public function pileUpIgnore(): static { - $this->pileUpPolicy = PileUpPolicy::IGNORE; + $this->pileUpPolicy = PileUpPolicy::Ignore; return $this; } @@ -252,7 +252,7 @@ public function pileUpIgnore(): static public function pileUpPreempt( int $time = null ): static { - $this->pileUpPolicy = PileUpPolicy::PREEMPT; + $this->pileUpPolicy = PileUpPolicy::Preempt; if ($time !== null) { $this->preemptTime = $time; @@ -272,7 +272,7 @@ public function pileUpSleep( int $time = null, int $attempts = null ): static { - $this->pileUpPolicy = PileUpPolicy::SLEEP; + $this->pileUpPolicy = PileUpPolicy::Sleep; if ($time !== null) { $this->sleepTime = $time; @@ -293,7 +293,7 @@ public function pileUpSleep( public function pileUpValue( mixed $value ): static { - $this->pileUpPolicy = PileUpPolicy::VALUE; + $this->pileUpPolicy = PileUpPolicy::Value; $this->fallbackValue = $value; return $this; } @@ -582,7 +582,7 @@ protected function ensureFetched(): void $this->fetched = true; $policy = $this->getPileUpPolicy(); - if ($policy === PileUpPolicy::IGNORE) { + if ($policy === PileUpPolicy::Ignore) { return; } @@ -590,7 +590,7 @@ protected function ensureFetched(): void if ($this->isHit) { if ( - $policy === PileUpPolicy::PREEMPT && + $policy === PileUpPolicy::Preempt && $ttl > 0 && $ttl < $this->getPreemptTime() ) { @@ -621,15 +621,15 @@ protected function ensureFetched(): void return; } - if ($policy === PileUpPolicy::SLEEP) { - $options = [$policy, PileUpPolicy::VALUE]; + if ($policy === PileUpPolicy::Sleep) { + $options = [$policy, PileUpPolicy::Value]; } else { - $options = [$policy, PileUpPolicy::SLEEP]; + $options = [$policy, PileUpPolicy::Sleep]; } foreach ($options as $option) { switch ($option) { - case PileUpPolicy::VALUE: + case PileUpPolicy::Value: if ($this->fallbackValue !== null) { $this->value = $this->fallbackValue; $this->isHit = true; @@ -638,7 +638,7 @@ protected function ensureFetched(): void break; - case PileUpPolicy::SLEEP: + case PileUpPolicy::Sleep: $attempts = $this->getSleepAttempts(); $time = $this->getSleepTime(); diff --git a/src/Stash/PileUpPolicy.php b/src/Stash/PileUpPolicy.php index 20f342b..f92270c 100644 --- a/src/Stash/PileUpPolicy.php +++ b/src/Stash/PileUpPolicy.php @@ -11,8 +11,8 @@ enum PileUpPolicy: string { - case IGNORE = 'ignore'; - case PREEMPT = 'preempt'; - case SLEEP = 'sleep'; - case VALUE = 'value'; + case Ignore = 'ignore'; + case Preempt = 'preempt'; + case Sleep = 'sleep'; + case Value = 'value'; } diff --git a/src/Stash/Store/Generic.php b/src/Stash/Store/Generic.php index 5e0189a..db5873c 100644 --- a/src/Stash/Store/Generic.php +++ b/src/Stash/Store/Generic.php @@ -31,7 +31,7 @@ class Generic implements Store */ protected array $deferred = []; - protected PileUpPolicy $pileUpPolicy = PileUpPolicy::PREEMPT; + protected PileUpPolicy $pileUpPolicy = PileUpPolicy::Preempt; /** * @phpstan-var positive-int @@ -494,7 +494,7 @@ public function getDriverKeys(): array */ public function pileUpIgnore(): static { - $this->pileUpPolicy = PileUpPolicy::IGNORE; + $this->pileUpPolicy = PileUpPolicy::Ignore; return $this; } @@ -504,7 +504,7 @@ public function pileUpIgnore(): static public function pileUpPreempt( int $preemptTime = null ): static { - $this->pileUpPolicy = PileUpPolicy::PREEMPT; + $this->pileUpPolicy = PileUpPolicy::Preempt; if ($preemptTime !== null) { $this->preemptTime = $preemptTime; @@ -520,7 +520,7 @@ public function pileUpSleep( int $time = null, int $attempts = null ): static { - $this->pileUpPolicy = PileUpPolicy::SLEEP; + $this->pileUpPolicy = PileUpPolicy::Sleep; if ($time !== null) { $this->sleepTime = $time; @@ -538,7 +538,7 @@ public function pileUpSleep( */ public function pileUpValue(): static { - $this->pileUpPolicy = PileUpPolicy::VALUE; + $this->pileUpPolicy = PileUpPolicy::Value; return $this; }