Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename isEnabled method to isActive #10

Merged
merged 3 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/CloudflareCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,19 @@ public function purgeByUrls(array $urls): bool|string
]);
}

public function isEnabled(): bool
public function isActive(): bool
{
if (app()->runningUnitTests()) {
return true;
}

if (! config('cloudflare-cache.api_email')
|| ! config('cloudflare-cache.api_key')
|| ! config('cloudflare-cache.identifier')
) {
return false;
}

if (config('cloudflare-cache.debug')) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/CloudflarePagesMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function shouldCacheResponse(Request $request, Response $response): bool
return false;
}

if (! CloudflareCacheFacade::isEnabled() && ! app()->runningUnitTests()) {
if (! CloudflareCacheFacade::isActive() && ! app()->runningUnitTests()) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Facades/CloudflareCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* @see \Yediyuz\CloudflareCache\CloudflareCache
*
* @method static bool isEnabled()
* @method static bool isActive()
* @method static bool|string purgeEverything()
* @method static bool|string purgeByPrefixes(array $prefixes)
* @method static bool|string purgeByTags(array $tags)
Expand Down
6 changes: 3 additions & 3 deletions src/Services/CloudflareService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class CloudflareService implements CloudflareServiceInterface
{
public function __construct(
private readonly Factory $client,
private readonly string $apiEmail,
private readonly string $apiKey,
private readonly string $identifier,
private readonly ?string $apiEmail,
private readonly ?string $apiKey,
private readonly ?string $identifier,
) {
// .
}
Expand Down
Loading