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

tempestphp / tempest-framework / 11799155234

12 Nov 2024 02:19PM UTC coverage: 82.551% (+0.1%) from 82.455%
11799155234

Pull #714

github

web-flow
Merge 0e4d40a29 into d599d5047
Pull Request #714: feat(routing): add regex chunking to route regex

71 of 73 new or added lines in 5 files covered. (97.26%)

19 existing lines in 2 files now uncovered.

7333 of 8883 relevant lines covered (82.55%)

49.18 hits per line

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

84.62
/src/Tempest/Http/src/Routing/Matching/MatchingRegex.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Http\Routing\Matching;
6

7
use RuntimeException;
8
use Tempest\Http\Routing\Construction\MarkedRoute;
9

10
final readonly class MatchingRegex
11
{
12
    /**
13
     * @param string[] $patterns
14
     */
15
    public function __construct(
19✔
16
        public array $patterns,
17
    ) {
18
    }
19✔
19

20
    public function match(string $uri): RouteMatch
19✔
21
    {
22
        foreach ($this->patterns as $pattern) {
19✔
23
            $matchResult = preg_match($pattern, $uri, $matches);
18✔
24

25
            if ($matchResult === false) {
18✔
NEW
26
                throw new RuntimeException("Failed to use matching regex. Got error " . preg_last_error());
×
27
            }
28

29
            if (! $matchResult) {
18✔
30
                continue;
7✔
31
            }
32

33
            if (! array_key_exists(MarkedRoute::REGEX_MARK_TOKEN, $matches)) {
14✔
NEW
34
                continue;
×
35
            }
36

37
            return RouteMatch::match($matches);
14✔
38
        }
39

40
        return RouteMatch::notFound();
5✔
41
    }
42
}
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