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

michalsn / codeigniter-htmx / 13707691824

06 Mar 2025 08:36PM UTC coverage: 74.783%. First build
13707691824

Pull #83

github

web-flow
Merge 7f79fbae7 into 2ec7f6426
Pull Request #83: chore: update workflow to support PHP 8.4

17 of 22 new or added lines in 6 files covered. (77.27%)

258 of 345 relevant lines covered (74.78%)

7.91 hits per line

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

77.27
/src/CodeIgniter.php
1
<?php
2

3
namespace Michalsn\CodeIgniterHtmx;
4

5
use CodeIgniter\CodeIgniter as BaseCodeIgniter;
6
use CodeIgniter\HTTP\CLIRequest;
7
use CodeIgniter\HTTP\DownloadResponse;
8
use CodeIgniter\HTTP\RedirectResponse;
9
use CodeIgniter\HTTP\URI;
10
use Michalsn\CodeIgniterHtmx\HTTP\IncomingRequest;
11

12
/**
13
 * @property CLIRequest|IncomingRequest|null $request
14
 */
15
class CodeIgniter extends BaseCodeIgniter
16
{
17
    /**
18
     * Web access?
19
     */
20
    private function isWeb(): bool
21
    {
22
        return $this->context === 'web';
2✔
23
    }
24

25
    /**
26
     * If we have a session object to use, store the current URI
27
     * as the previous URI. This is called just prior to sending the
28
     * response to the client, and will make it available next request.
29
     *
30
     * This helps provider safer, more reliable previous_url() detection.
31
     *
32
     * @param string|URI $uri
33
     *
34
     * @return void
35
     */
36
    public function storePreviousURL($uri)
37
    {
38
        // Ignore CLI requests
39
        if (! $this->isWeb()) {
2✔
40
            return;
×
41
        }
42

43
        // Ignore AJAX requests
44
        if (method_exists($this->request, 'isAJAX') && $this->request->isAJAX()) {
2✔
45
            return;
×
46
        }
47

48
        // Ignore HTMX requests
49
        if (config('Htmx')->storePreviousURL === false
2✔
50
            && method_exists($this->request, 'isHTMX') && $this->request->isHTMX()) {
2✔
51
            return;
1✔
52
        }
53

54
        // Ignore unroutable responses
55
        if ($this->response instanceof DownloadResponse || $this->response instanceof RedirectResponse) {
1✔
56
            return;
×
57
        }
58

59
        // Ignore non-HTML responses
60
        if (! str_contains($this->response->getHeaderLine('Content-Type'), 'text/html')) {
1✔
61
            return;
×
62
        }
63

64
        // This is mainly needed during testing...
65
        if (is_string($uri)) {
1✔
66
            $uri = service('uri', $uri, false);
×
67
        }
68

69
        if (isset($_SESSION)) {
1✔
70
            session()->set('_ci_previous_url', URI::createURIString(
1✔
71
                $uri->getScheme(),
1✔
72
                $uri->getAuthority(),
1✔
73
                $uri->getPath(),
1✔
74
                $uri->getQuery(),
1✔
75
                $uri->getFragment(),
1✔
76
            ));
1✔
77
        }
78
    }
79
}
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