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

NeoIsRecursive / inertia-tempest / 16102926170

06 Jul 2025 08:33PM UTC coverage: 96.373% (-1.9%) from 98.286%
16102926170

Pull #3

github

web-flow
Merge fd421ff7c into b3759af2c
Pull Request #3: feat: encryption and history clearing support

22 of 25 new or added lines in 2 files covered. (88.0%)

1 existing line in 1 file now uncovered.

186 of 193 relevant lines covered (96.37%)

11.55 hits per line

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

90.0
/src/Inertia.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace NeoIsRecursive\Inertia;
6

7
use NeoIsRecursive\Inertia\Http\InertiaResponse;
8
use NeoIsRecursive\Inertia\InertiaConfig;
9
use NeoIsRecursive\Inertia\Support\Header;
10
use Tempest\Container\Container;
11
use Tempest\Container\Singleton;
12
use Tempest\Http\GenericResponse;
13
use Tempest\Http\Request;
14
use Tempest\Http\Response;
15
use Tempest\Http\Responses\Redirect;
16
use Tempest\Http\Session\Session;
17
use Tempest\Http\Status;
18

19
#[Singleton]
20
final class Inertia
21
{
22
    public function __construct(
23
        private Session $session,
24
        private Container $container,
25
        private InertiaConfig $config,
26
    ) {}
12✔
27

28
    public function share(string|array $key, null|string $value = null): void
29
    {
30
        $this->config->share($key, $value);
3✔
31
    }
32

33
    public function flushShared(): void
34
    {
35
        $this->config->flushSharedProps();
1✔
36
    }
37

38
    public string $version {
39
        get => $this->container->invoke($this->config->versionResolver->resolve(...));
40
    }
41

42
    public function render(string $page, array $props = []): InertiaResponse
43
    {
44
        return new InertiaResponse(
4✔
45
            request: $this->container->get(Request::class),
4✔
46
            component: $page,
4✔
47
            props: array_merge($this->config->sharedProps, $props),
4✔
48
            rootView: $this->config->rootView,
4✔
49
            version: $this->version,
4✔
50
            clearHistory: $this->session->get(
4✔
51
                key: 'inertia.clear_history',
4✔
52
                default: false,
4✔
53
            ),
4✔
54
            encryptHistory: $this->session->get(
4✔
55
                key: 'inertia.encrypt_history',
4✔
56
                default: false,
4✔
57
            ),
4✔
58
        );
4✔
59
    }
60

61
    public function encryptHistory(): void
62
    {
63
        $this->session->flash(
1✔
64
            key: 'inertia.encrypt_history',
1✔
65
            value: true,
1✔
66
        );
1✔
67
    }
68

69
    public function clearHistory(): void
70
    {
NEW
71
        $this->session->flash(
×
NEW
72
            key: 'inertia.clear_history',
×
NEW
73
            value: true,
×
UNCOV
74
        );
×
75
    }
76

77
    public function location(string|Redirect $url): Response
78
    {
79
        $isInertiaRequest = $this
6✔
80
            ->container->get(Request::class)
6✔
81
            ->headers->has(Header::INERTIA);
6✔
82

83
        if ($isInertiaRequest) {
6✔
84
            if ($url instanceof Redirect) {
2✔
85
                $url = $url->getHeader(name: 'Location')->values[0];
1✔
86
            }
87

88
            return new GenericResponse(
2✔
89
                status: Status::CONFLICT,
2✔
90
                body: '',
2✔
91
                headers: [
2✔
92
                    Header::LOCATION => $url,
2✔
93
                ],
2✔
94
            );
2✔
95
        }
96

97
        return ($url instanceof Redirect) ? $url : new Redirect($url);
4✔
98
    }
99
}
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