-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
852 additions
and
483 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SpomkyLabs\PwaBundle\Dto; | ||
|
||
use DateInterval; | ||
use DateTimeImmutable; | ||
use Symfony\Component\Serializer\Attribute\SerializedName; | ||
use function is_string; | ||
|
||
abstract class Cache | ||
{ | ||
#[SerializedName('cache_name')] | ||
public null|string $cacheName = null; | ||
|
||
#[SerializedName('max_age')] | ||
public null|string|int $maxAge = null; | ||
|
||
#[SerializedName('max_entries')] | ||
public null|int $maxEntries = 60; | ||
|
||
public function maxAgeInSeconds(): null|int | ||
{ | ||
if ($this->maxAge === null) { | ||
return null; | ||
} | ||
if (is_string($this->maxAge)) { | ||
$now = new DateTimeImmutable(); | ||
$future = $now->add(DateInterval::createFromDateString($this->maxAge)); | ||
return abs($future->getTimestamp() - $now->getTimestamp()); | ||
} | ||
return $this->maxAge; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,21 +6,33 @@ | |
|
||
use Symfony\Component\Serializer\Attribute\SerializedName; | ||
|
||
final class PageCache | ||
final class PageCache extends Cache | ||
{ | ||
#[SerializedName('cache_name')] | ||
public string $cacheName; | ||
|
||
#[SerializedName('regex')] | ||
public string $regex; | ||
#[SerializedName('match_callback')] | ||
public string $matchCallback; | ||
|
||
#[SerializedName('network_timeout')] | ||
public int $networkTimeout = 3; | ||
|
||
public string $strategy = 'networkFirst'; | ||
public string $strategy = 'NetworkFirst'; | ||
|
||
public bool $broadcast = false; | ||
|
||
#[SerializedName('range_requests')] | ||
public bool $rangeRequests = false; | ||
|
||
/** | ||
* @var int[] | ||
*/ | ||
#[SerializedName('cacheable_response_statuses')] | ||
public array $cacheableResponseStatuses = [0, 200]; | ||
|
||
/** | ||
* @var null|array<string, string> | ||
*/ | ||
#[SerializedName('cacheable_response_headers')] | ||
public array $cacheableResponseHeaders = []; | ||
Check failure on line 34 in src/Dto/PageCache.php GitHub Actions / PHP 8.3 Test on ubuntu-latest
|
||
|
||
/** | ||
* @var array<string> | ||
*/ | ||
|
@@ -30,5 +42,6 @@ final class PageCache | |
/** | ||
* @var array<Url> | ||
*/ | ||
#[SerializedName('preload_urls')] | ||
public array $urls = []; | ||
} |
Oops, something went wrong.