Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| InMemoryPersistentSessionStorageFactory | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| createStorage | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Apie\IntegrationTests\Applications\Symfony; |
| 3 | |
| 4 | use Symfony\Component\HttpFoundation\Request; |
| 5 | use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; |
| 6 | use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageFactoryInterface; |
| 7 | use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface; |
| 8 | use Symfony\Component\HttpKernel\KernelInterface; |
| 9 | use WeakMap; |
| 10 | |
| 11 | class InMemoryPersistentSessionStorageFactory implements SessionStorageFactoryInterface |
| 12 | { |
| 13 | /** @var WeakMap<KernelInterface, SessionStorageInterface>|null */ |
| 14 | private static ?WeakMap $sessionStorages = null; |
| 15 | |
| 16 | public function __construct(private readonly KernelInterface $kernel) |
| 17 | { |
| 18 | } |
| 19 | |
| 20 | public function createStorage(?Request $request): SessionStorageInterface |
| 21 | { |
| 22 | self::$sessionStorages ??= new WeakMap(); |
| 23 | if (isset(self::$sessionStorages[$this->kernel])) { |
| 24 | return self::$sessionStorages[$this->kernel]; |
| 25 | } |
| 26 | |
| 27 | return self::$sessionStorages[$this->kernel] = new MockArraySessionStorage(); |
| 28 | } |
| 29 | } |