Skip to content

Commit

Permalink
Merge pull request #10 from yediyuz/is-enabled
Browse files Browse the repository at this point in the history
Rename isEnabled method to isActive
  • Loading branch information
mertasan authored Mar 10, 2024
2 parents a36eb94 + fe9f260 commit 55f167f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
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

0 comments on commit 55f167f

Please sign in to comment.