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

tempestphp / tempest-framework / 9045933531

11 May 2024 07:25PM UTC coverage: 86.566% (+0.3%) from 86.24%
9045933531

Pull #240

github

web-flow
Merge ef4f1596e into d6a8ae2f5
Pull Request #240: feat: Adds Timebox utility class and extends Clock

30 of 33 new or added lines in 4 files covered. (90.91%)

21 existing lines in 4 files now uncovered.

1321 of 1526 relevant lines covered (86.57%)

10.51 hits per line

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

64.0
/src/functions.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest {
6

7
    use Tempest\Commands\CommandBus;
8
    use Tempest\Http\GenericResponse;
9
    use Tempest\Http\Response;
10
    use Tempest\Http\Router;
11
    use Tempest\Http\Status;
12
    use Tempest\View\GenericView;
13
    use Tempest\View\View;
14

15
    function path(string ...$parts): string
16
    {
17
        $path = implode('/', $parts);
24✔
18

19
        return str_replace(
24✔
20
            ['//', '\\', '\\\\'],
24✔
21
            ['/', '/', '/'],
24✔
22
            $path,
24✔
23
        );
24✔
24
    }
25

26
    function view(string $path): View
27
    {
28
        return new GenericView($path);
11✔
29
    }
30

31
    function response(string $body = '', Status $status = Status::OK): Response
32
    {
33
        return new GenericResponse($status, $body);
16✔
34
    }
35

36
    function uri(array|string $action, ...$params): string
37
    {
38
        $router = get(Router::class);
6✔
39

40
        return $router->toUri(
6✔
41
            $action,
6✔
42
            ...$params,
6✔
43
        );
6✔
44
    }
45

46
    function redirect(string|array $action, ...$params): Response
47
    {
48
        return response()->redirect(uri($action, ...$params));
2✔
49
    }
50

51
    function command(object $command): void
52
    {
53
        $commandBus = get(CommandBus::class);
3✔
54

55
        $commandBus->dispatch($command);
3✔
56
    }
57

58
    function env(string $key, mixed $default = null): mixed
59
    {
UNCOV
60
        $value = getenv($key);
×
61

UNCOV
62
        if ($value === false) {
×
UNCOV
63
            return $default;
×
64
        }
65

UNCOV
66
        return match (strtolower($value)) {
×
UNCOV
67
            'true' => true,
×
UNCOV
68
            'false' => false,
×
UNCOV
69
            'null', '' => null,
×
UNCOV
70
            default => $value,
×
UNCOV
71
        };
×
72
    }
73
}
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