• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tempestphp / tempest-framework / 14049246919

24 Mar 2025 09:42PM UTC coverage: 79.353% (-0.04%) from 79.391%
14049246919

push

github

web-flow
feat(support): support array parameters in string manipulations (#1073)

48 of 48 new or added lines in 2 files covered. (100.0%)

735 existing lines in 126 files now uncovered.

10492 of 13222 relevant lines covered (79.35%)

90.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.97
/src/Tempest/Router/src/Session/Session.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Router\Session;
6

7
use DateTimeImmutable;
8

9
use function Tempest\get;
10

11
final class Session
12
{
13
    public const string ID = 'tempest_session_id';
14

15
    public const string VALIDATION_ERRORS = 'validation_errors';
16

17
    public const string ORIGINAL_VALUES = 'original_values';
18

19
    private array $expiredKeys = [];
20

21
    public function __construct(
44✔
22
        public SessionId $id,
23
        public DateTimeImmutable $createdAt,
24
        /** @var array<array-key, mixed> */
25
        public array $data = [],
26
    ) {}
44✔
27

28
    public function set(string $key, mixed $value): void
7✔
29
    {
30
        $this->getSessionManager()->set($this->id, $key, $value);
7✔
31
    }
32

33
    public function flash(string $key, mixed $value): void
5✔
34
    {
35
        $this->getSessionManager()->set($this->id, $key, new FlashValue($value));
5✔
36
    }
37

38
    public function get(string $key, mixed $default = null): mixed
15✔
39
    {
40
        $value = $this->getSessionManager()->get($this->id, $key, $default);
15✔
41

42
        if ($value instanceof FlashValue) {
15✔
43
            $this->expiredKeys[$key] = $key;
5✔
44
            $value = $value->value;
5✔
45
        }
46

47
        return $value;
15✔
48
    }
49

UNCOV
50
    public function consume(string $key, mixed $default = null): mixed
×
51
    {
UNCOV
52
        $value = $this->get($key, $default);
×
53

UNCOV
54
        $this->remove($key);
×
55

UNCOV
56
        return $value;
×
57
    }
58

UNCOV
59
    public function all(): array
×
60
    {
UNCOV
61
        return $this->getSessionManager()->all($this->id);
×
62
    }
63

64
    public function remove(string $key): void
3✔
65
    {
66
        $this->getSessionManager()->remove($this->id, $key);
3✔
67
    }
68

69
    public function destroy(): void
4✔
70
    {
71
        $this->getSessionManager()->destroy($this->id);
4✔
72
    }
73

74
    public function isValid(): bool
1✔
75
    {
76
        return $this->getSessionManager()->isValid($this->id);
1✔
77
    }
78

UNCOV
79
    public function cleanup(): void
×
80
    {
UNCOV
81
        foreach ($this->expiredKeys as $key) {
×
82
            $this->getSessionManager()->remove($this->id, $key);
×
83
        }
84
    }
85

86
    private function getSessionManager(): SessionManager
18✔
87
    {
88
        return get(SessionManager::class);
18✔
89
    }
90
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc