Lines 100.00% 6 / 6
Functions and Methods 100.00% 4 / 4
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
Session 100.00% 6 / 6 100.00% 4 / 4 4 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 set 100.00% 1 / 1 100.00% 1 / 1 1
 getAndDelete 100.00% 3 / 3 100.00% 1 / 1 1
 delete 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Districts\Editor\UI;
6
7use SlimSession\Helper;
8
9final readonly class Session
10{
11    /**
12     * @param Helper<mixed> $helper
13     */
14    public function __construct(
15        private Helper $helper,
16    ) {
17    }
18
19    public function set(string $key, mixed $value): void
20    {
21        $this->helper->set($key, $value);
22    }
23
24    public function getAndDelete(string $key, mixed $default = null): mixed
25    {
26        $value = $this->helper->get($key, $default);
27        $this->helper->delete($key);
28        return $value;
29    }
30
31    public function delete(string $key): void
32    {
33        $this->helper->delete($key);
34    }
35}