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

tempestphp / tempest-framework / 11834579899

14 Nov 2024 09:41AM UTC coverage: 82.65% (+0.05%) from 82.602%
11834579899

Pull #726

github

web-flow
Merge ecef5860e into 0bdee919e
Pull Request #726: fix(console): handle nested `style` tags

68 of 68 new or added lines in 3 files covered. (100.0%)

26 existing lines in 5 files now uncovered.

7617 of 9216 relevant lines covered (82.65%)

51.59 hits per line

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

84.91
/src/Tempest/Http/src/IsRequest.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Http;
6

7
use function Tempest\get;
8
use Tempest\Http\Cookie\Cookie;
9
use Tempest\Http\Cookie\CookieManager;
10
use Tempest\Http\Session\Session;
11

12
/** @phpstan-require-implements \Tempest\Http\Request */
13
trait IsRequest
14
{
15
    public string $path;
16

17
    public array $query;
18

19
    /** @var \Tempest\Http\Upload[] */
20
    public array $files;
21

22
    public function __construct(
379✔
23
        public Method $method,
24
        public string $uri,
25
        public array $body = [],
26
        public array $headers = [],
27
    ) {
28
        $this->path ??= $this->resolvePath();
379✔
29
        $this->query ??= $this->resolveQuery();
379✔
30
        $this->files ??= [];
379✔
31
    }
32

33
    public function get(string $key, mixed $default = null): mixed
1✔
34
    {
35
        if (array_key_exists($key, $this->body)) {
1✔
36
            return $this->body[$key];
1✔
37
        }
38

39
        if (array_key_exists($key, $this->query)) {
1✔
40
            return $this->query[$key];
1✔
41
        }
42

43
        return $default;
1✔
44
    }
45

46
    public function getMethod(): Method
31✔
47
    {
48
        return $this->method;
31✔
49
    }
50

51
    public function getUri(): string
31✔
52
    {
53
        return $this->uri;
31✔
54
    }
55

56
    public function getBody(): array
32✔
57
    {
58
        return $this->body;
32✔
59
    }
60

61
    public function getHeaders(): array
34✔
62
    {
63
        return $this->headers;
34✔
64
    }
65

UNCOV
66
    public function getPath(): string
×
67
    {
UNCOV
68
        return $this->path;
×
69
    }
70

71
    public function getQuery(): array
21✔
72
    {
73
        return $this->query;
21✔
74
    }
75

76
    /** @return \Tempest\Http\Upload[] */
77
    public function getFiles(): array
23✔
78
    {
79
        return $this->files;
23✔
80
    }
81

UNCOV
82
    public function getSessionValue(string $name): mixed
×
83
    {
84
        /** @var Session $session */
UNCOV
85
        $session = get(Session::class);
×
86

UNCOV
87
        return $session->get($name);
×
88
    }
89

UNCOV
90
    public function getCookie(string $name): ?Cookie
×
91
    {
92
        /** @var CookieManager $cookies */
UNCOV
93
        $cookies = get(CookieManager::class);
×
94

UNCOV
95
        return $cookies->get($name);
×
96
    }
97

98
    public function getCookies(): array
21✔
99
    {
100
        /** @var CookieManager $cookies */
101
        $cookies = get(CookieManager::class);
21✔
102

103
        return $cookies->all();
21✔
104
    }
105

106
    public function validate(): void
24✔
107
    {
108
        // No additional validation done
109
    }
24✔
110

111
    private function resolvePath(): string
379✔
112
    {
113
        $decodedUri = rawurldecode($this->uri);
379✔
114
        $parsedUrl = parse_url($decodedUri);
379✔
115

116
        return $parsedUrl['path'] ?? '';
379✔
117
    }
118

119
    private function resolveQuery(): array
379✔
120
    {
121
        $decodedUri = rawurldecode($this->uri);
379✔
122
        $parsedUrl = parse_url($decodedUri);
379✔
123
        $queryString = $parsedUrl['query'] ?? '';
379✔
124

125
        parse_str($queryString, $query);
379✔
126

127
        return $query;
379✔
128
    }
129

130
    public function has(string $key): bool
1✔
131
    {
132
        if ($this->hasBody($key)) {
1✔
133
            return true;
1✔
134
        }
135

136
        return (bool) $this->hasQuery($key);
1✔
137
    }
138

139
    public function hasBody(string $key): bool
1✔
140
    {
141
        return array_key_exists($key, $this->body);
1✔
142
    }
143

144
    public function hasQuery(string $key): bool
1✔
145
    {
146
        return array_key_exists($key, $this->query);
1✔
147
    }
148
}
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