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

tempestphp / tempest-framework / 14322727335

07 Apr 2025 03:10PM UTC coverage: 81.259% (+0.4%) from 80.906%
14322727335

push

github

web-flow
fix(support): non-dev bun dependencies installation (#1124)

0 of 12 new or added lines in 1 file covered. (0.0%)

25 existing lines in 6 files now uncovered.

11434 of 14071 relevant lines covered (81.26%)

105.02 hits per line

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

72.73
/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
    public const string PREVIOUS_URL = '_previous_url';
20

21
    private array $expiredKeys = [];
22

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

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

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

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

44
        if ($value instanceof FlashValue) {
19✔
45
            $this->expiredKeys[$key] = $key;
5✔
46
            $value = $value->value;
5✔
47
        }
48

49
        return $value;
19✔
50
    }
51

52
    public function getPreviousUrl(): string
1✔
53
    {
54
        return $this->get(self::PREVIOUS_URL, '');
1✔
55
    }
56

57
    public function setPreviousUrl(string $url): void
31✔
58
    {
59
        $this->set(self::PREVIOUS_URL, $url);
31✔
60
    }
61

UNCOV
62
    public function consume(string $key, mixed $default = null): mixed
×
63
    {
UNCOV
64
        $value = $this->get($key, $default);
×
65

UNCOV
66
        $this->remove($key);
×
67

UNCOV
68
        return $value;
×
69
    }
70

UNCOV
71
    public function all(): array
×
72
    {
UNCOV
73
        return $this->getSessionManager()->all($this->id);
×
74
    }
75

76
    public function remove(string $key): void
3✔
77
    {
78
        $this->getSessionManager()->remove($this->id, $key);
3✔
79
    }
80

81
    public function destroy(): void
4✔
82
    {
83
        $this->getSessionManager()->destroy($this->id);
4✔
84
    }
85

86
    public function isValid(): bool
1✔
87
    {
88
        return $this->getSessionManager()->isValid($this->id);
1✔
89
    }
90

UNCOV
91
    public function cleanup(): void
×
92
    {
UNCOV
93
        foreach ($this->expiredKeys as $key) {
×
UNCOV
94
            $this->getSessionManager()->remove($this->id, $key);
×
95
        }
96
    }
97

98
    private function getSessionManager(): SessionManager
50✔
99
    {
100
        return get(SessionManager::class);
50✔
101
    }
102
}
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