Skip to content

Commit

Permalink
Renamed enums to PascalCase
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Wright <[email protected]>
  • Loading branch information
betterthanclay committed Nov 14, 2023
1 parent def3777 commit 501b0a3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Renamed enums to PascalCase

## v0.2.1 (2023-11-09)
* Improved selection of drivers to purge

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
"extra": {
"branch-alias": {
"dev-develop": "0.2.x-dev"
"dev-develop": "0.3.x-dev"
}
}
}
22 changes: 11 additions & 11 deletions src/Stash/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function getTimeRemaining(): ?CarbonInterval
*/
public function pileUpIgnore(): static
{
$this->pileUpPolicy = PileUpPolicy::IGNORE;
$this->pileUpPolicy = PileUpPolicy::Ignore;
return $this;
}

Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -582,15 +582,15 @@ protected function ensureFetched(): void
$this->fetched = true;
$policy = $this->getPileUpPolicy();

if ($policy === PileUpPolicy::IGNORE) {
if ($policy === PileUpPolicy::Ignore) {
return;
}

$ttl = $this->expiration ? $this->expiration->getTimestamp() - $time : null;

if ($this->isHit) {
if (
$policy === PileUpPolicy::PREEMPT &&
$policy === PileUpPolicy::Preempt &&
$ttl > 0 &&
$ttl < $this->getPreemptTime()
) {
Expand Down Expand Up @@ -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;
Expand All @@ -638,7 +638,7 @@ protected function ensureFetched(): void

break;

case PileUpPolicy::SLEEP:
case PileUpPolicy::Sleep:
$attempts = $this->getSleepAttempts();
$time = $this->getSleepTime();

Expand Down
8 changes: 4 additions & 4 deletions src/Stash/PileUpPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
10 changes: 5 additions & 5 deletions src/Stash/Store/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -494,7 +494,7 @@ public function getDriverKeys(): array
*/
public function pileUpIgnore(): static
{
$this->pileUpPolicy = PileUpPolicy::IGNORE;
$this->pileUpPolicy = PileUpPolicy::Ignore;
return $this;
}

Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -538,7 +538,7 @@ public function pileUpSleep(
*/
public function pileUpValue(): static
{
$this->pileUpPolicy = PileUpPolicy::VALUE;
$this->pileUpPolicy = PileUpPolicy::Value;
return $this;
}

Expand Down

0 comments on commit 501b0a3

Please sign in to comment.