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

RonasIT / laravel-swagger / 26501140370

27 May 2026 08:51AM UTC coverage: 99.573% (-0.08%) from 99.656%
26501140370

Pull #193

github

web-flow
Merge d3351ea28 into a9abd440c
Pull Request #193: feat: name response object by resource class

136 of 137 new or added lines in 9 files covered. (99.27%)

1 existing line in 1 file now uncovered.

932 of 936 relevant lines covered (99.57%)

24.06 hits per line

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

94.44
/src/RequestContext/Extractors/RouteExtractor.php
1
<?php
2

3
namespace RonasIT\AutoDoc\RequestContext\Extractors;
4

5
use Closure;
6
use Illuminate\Routing\Route;
7
use RonasIT\AutoDoc\Exceptions\NonClosureControllerException;
8

9
class RouteExtractor
10
{
11
    private const string CLOSURE_ACTION_NAME = 'Closure';
12

13
    public readonly ?string $controllerClass;
14
    public readonly ?string $controllerMethod;
15
    public readonly bool $isClosureAction;
16
    public readonly array $wheres;
17

18
    public function __construct(
19
        protected Route $route,
20
    ) {
21
        $this->wheres = $this->route->wheres;
37✔
22

23
        $actionName = $route->getActionName();
37✔
24
        $this->isClosureAction = ($actionName === self::CLOSURE_ACTION_NAME);
37✔
25

26
        $actionParts = explode('@', $actionName);
37✔
27

28
        $this->controllerClass = $actionParts[0] ?? null;
37✔
29

30
        $this->controllerMethod = (is_null($this->controllerClass)) ? null : $actionParts[1] ?? '__invoke';
37✔
31
    }
32

33
    public function getClosure(): Closure
34
    {
35
        $uses = $this->route->getAction('uses');
4✔
36

37
        if (!$uses instanceof Closure) {
4✔
38
            throw new NonClosureControllerException();
1✔
39
        }
40

41
        return $uses;
3✔
42
    }
43

44
    public function getUri(): string
45
    {
46
        $basePath = ltrim(config('auto-doc.basePath'), '/');
36✔
47

48
        $routeUri = $this->route->uri();
36✔
49

50
        $isContainsBasePath = $basePath !== ''
36✔
51
            && str_starts_with($routeUri, $basePath);
36✔
52

53
        $uri = $isContainsBasePath
36✔
NEW
54
            ? substr($routeUri, strlen($basePath))
×
55
            : $routeUri;
36✔
56

57
        return '/' . ltrim($uri, '/');
36✔
58
    }
59
}
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