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

NeoIsRecursive / inertia-tempest / 16110679938

07 Jul 2025 07:29AM UTC coverage: 95.939% (-2.3%) from 98.286%
16110679938

Pull #3

github

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

26 of 31 new or added lines in 3 files covered. (83.87%)

189 of 197 relevant lines covered (95.94%)

11.33 hits per line

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

88.64
/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): self
29
    {
30
        $this->config->share($key, $value);
3✔
31

32
        return $this;
3✔
33
    }
34

35
    public function flushShared(): self
36
    {
37
        $this->config->flushSharedProps();
1✔
38

39
        return $this;
1✔
40
    }
41

42
    public string $version {
43
        get => $this->container->invoke($this->config->versionResolver->resolve(...));
44
    }
45

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

65
    public function encryptHistory(): self
66
    {
67
        $this->session->flash(
1✔
68
            key: 'inertia.encrypt_history',
1✔
69
            value: true,
1✔
70
        );
1✔
71

72
        return $this;
1✔
73
    }
74

75
    public function clearHistory(): self
76
    {
NEW
77
        $this->session->flash(
×
NEW
78
            key: 'inertia.clear_history',
×
NEW
79
            value: true,
×
NEW
80
        );
×
81

NEW
82
        return $this;
×
83
    }
84

85
    public function location(string|Redirect $url): Response
86
    {
87
        $isInertiaRequest = $this
6✔
88
            ->container->get(Request::class)
6✔
89
            ->headers->has(Header::INERTIA);
6✔
90

91
        if ($isInertiaRequest) {
6✔
92
            if ($url instanceof Redirect) {
2✔
93
                $url = $url->getHeader(name: 'Location')->values[0];
1✔
94
            }
95

96
            return new GenericResponse(
2✔
97
                status: Status::CONFLICT,
2✔
98
                body: '',
2✔
99
                headers: [
2✔
100
                    Header::LOCATION => $url,
2✔
101
                ],
2✔
102
            );
2✔
103
        }
104

105
        return ($url instanceof Redirect) ? $url : new Redirect($url);
4✔
106
    }
107
}
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