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

willy68 / pg-router / 16153203361

08 Jul 2025 08:00PM UTC coverage: 94.978% (+13.9%) from 81.095%
16153203361

push

github

willy68
First commit

30 of 32 new or added lines in 4 files covered. (93.75%)

5 existing lines in 1 file now uncovered.

870 of 916 relevant lines covered (94.98%)

8.34 hits per line

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

90.0
/src/RegexCollector/NamedRegexCollector.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Pg\Router\RegexCollector;
6

7
use Pg\Router\Parser\NamedParser;
8
use Pg\Router\Parser\ParserInterface;
9
use Pg\Router\Route;
10

11
class NamedRegexCollector implements RegexCollectorInterface
12
{
13
    protected array $routes = [];
14
    protected ?array $data = null;
15
    private ?ParserInterface $parser;
16

17
    public function __construct(ParserInterface $parser = null)
8✔
18
    {
19
        $this->parser = $parser;
8✔
20
    }
21

22
    /**
23
     * @inheritDoc
24
     */
25
    public function addRoute(Route $route): void
8✔
26
    {
27
        $this->routes[] = $route;
8✔
28
    }
29

NEW
30
    public function addRoutes(array $routes): void
×
31
    {
NEW
32
        $this->routes = array_merge($this->routes, $routes);
×
33
    }
34

35
    /**
36
     * @inheritDoc
37
     */
38
    public function getData(): array
8✔
39
    {
40
        $this->parseRoutes($this->routes);
8✔
41
        return $this->data;
8✔
42
    }
43

44
    protected function parseRoutes(array $routes): void
8✔
45
    {
46
        foreach ($routes as $route) {
8✔
47
            $methods = $route->getAllowedMethods() ?? [self::ANY_METHODS];
8✔
48
            $name = $route->getName();
8✔
49

50
            $regex = $this->getParser()->parse($route->getPath());
8✔
51

52
            foreach ($methods as $method) {
8✔
53
                $this->data[$method][$name] = ['regex' => $regex];
8✔
54
            }
55
        }
56
    }
57

58
    protected function getParser(): ParserInterface
8✔
59
    {
60
        if (!$this->parser) {
8✔
61
            $this->parser = new NamedParser();
8✔
62
        }
63

64
        return $this->parser;
8✔
65
    }
66
}
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