Skip to content

Commit 3bc4e14

Browse files
committed
typo
1 parent 282fb7c commit 3bc4e14

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/Bridges/Psr/PsrCacheAdapter.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717

1818
class PsrCacheAdapter implements Psr\SimpleCache\CacheInterface
1919
{
20-
public function __construct(private Nette\Caching\Storage $storage)
21-
{
20+
public function __construct(
21+
private Nette\Caching\Storage $storage,
22+
) {
2223
}
2324

2425

@@ -98,6 +99,7 @@ public function has(string $key): bool
9899
return $this->storage->read($key) !== null;
99100
}
100101

102+
101103
private static function ttlToSeconds(null|int|DateInterval $ttl = null): ?int
102104
{
103105
if ($ttl instanceof DateInterval) {
@@ -107,12 +109,12 @@ private static function ttlToSeconds(null|int|DateInterval $ttl = null): ?int
107109
return $ttl;
108110
}
109111

112+
110113
private static function dateIntervalToSeconds(DateInterval $dateInterval): int
111114
{
112115
$now = new DateTimeImmutable();
113116
$expiresAt = $now->add($dateInterval);
114117

115118
return $expiresAt->getTimestamp() - $now->getTimestamp();
116119
}
117-
118120
}

tests/Bridges.Psr/PsrCacheAdapter.set.phpt

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test('set ttl int', function () {
2727
Assert::same([
2828
'data' => '2',
2929
'dependencies' => [
30-
Caching\Cache::Expire => 1
30+
Caching\Cache::Expire => 1,
3131
],
3232
], $storage->read('test'));
3333
});
@@ -40,27 +40,27 @@ test('set ttl DateInterval', function () {
4040
Assert::same([
4141
'data' => '3',
4242
'dependencies' => [
43-
Caching\Cache::Expire => 110899805
43+
Caching\Cache::Expire => 110_899_805,
4444
],
4545
], $storage->read('test'));
4646

4747
$from = new DateTime('1978-01-23 05:06:07');
4848
$to = new DateTime('1986-12-30 07:08:09');
49-
Assert::same(281930522, $to->getTimestamp() - $from->getTimestamp());
49+
Assert::same(281_930_522, $to->getTimestamp() - $from->getTimestamp());
5050

5151
$cache->set('test', '4', ($from)->diff($to));
5252
Assert::same([
5353
'data' => '4',
5454
'dependencies' => [
55-
Caching\Cache::Expire => 282016922
55+
Caching\Cache::Expire => 282_016_922,
5656
],
5757
], $storage->read('test'));
5858

5959
$cache->set('test', '5', (new DateTime('1986-12-30 07:08:09'))->diff(new DateTime('1978-01-23 05:06:07')));
6060
Assert::same([
6161
'data' => '5',
6262
'dependencies' => [
63-
Caching\Cache::Expire => -282016922
63+
Caching\Cache::Expire => -282_016_922,
6464
],
6565
], $storage->read('test'));
6666
});

tests/Bridges.Psr/PsrCacheAdapter.setMultiple.phpt

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ test('set multiple ttl int', function () {
3434
Assert::same([
3535
'data' => '1',
3636
'dependencies' => [
37-
Caching\Cache::Expire => 1
37+
Caching\Cache::Expire => 1,
3838
],
3939
], $storage->read('test1'));
4040

4141
Assert::same([
4242
'data' => '2',
4343
'dependencies' => [
44-
Caching\Cache::Expire => 1
44+
Caching\Cache::Expire => 1,
4545
],
4646
], $storage->read('test2'));
4747
});
@@ -54,14 +54,14 @@ test('set multiple ttl DateInterval', function () {
5454
Assert::same([
5555
'data' => '1',
5656
'dependencies' => [
57-
Caching\Cache::Expire => 110899805
57+
Caching\Cache::Expire => 110_899_805,
5858
],
5959
], $storage->read('test1'));
6060

6161
Assert::same([
6262
'data' => '2',
6363
'dependencies' => [
64-
Caching\Cache::Expire => 110899805
64+
Caching\Cache::Expire => 110_899_805,
6565
],
6666
], $storage->read('test2'));
6767
});

0 commit comments

Comments
 (0)