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

donatj / mock-webserver / 15544212778

09 Jun 2025 08:42PM UTC coverage: 78.841% (-1.4%) from 80.24%
15544212778

push

github

web-flow
Merge pull request #61 from donatj/feature/phpstan

Add phpstan to ci

5 of 12 new or added lines in 4 files covered. (41.67%)

1 existing line in 1 file now uncovered.

272 of 345 relevant lines covered (78.84%)

4.26 hits per line

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

90.0
/src/RequestInfo.php
1
<?php
2

3
namespace donatj\MockWebServer;
4

5
use donatj\MockWebServer\Exceptions\RuntimeException;
6

7
class RequestInfo implements \JsonSerializable {
8

9
        public const JSON_KEY_GET          = '_GET';
10
        public const JSON_KEY_POST         = '_POST';
11
        public const JSON_KEY_FILES        = '_FILES';
12
        public const JSON_KEY_COOKIE       = '_COOKIE';
13
        public const JSON_KEY_HEADERS      = 'HEADERS';
14
        public const JSON_KEY_METHOD       = 'METHOD';
15
        public const JSON_KEY_INPUT        = 'INPUT';
16
        public const JSON_KEY_PARSED_INPUT = 'PARSED_INPUT';
17
        public const JSON_KEY_REQUEST_URI  = 'REQUEST_URI';
18

19
        public const JSON_KEY_PARSED_REQUEST_URI = 'PARSED_REQUEST_URI';
20

21
        /** @var array */
22
        private $parsedUri;
23
        /** @var array */
24
        private $server;
25
        /** @var array */
26
        private $get;
27
        /** @var array */
28
        private $post;
29
        /** @var array */
30
        private $files;
31
        /** @var array */
32
        private $cookie;
33
        /** @var array */
34
        private $HEADERS;
35
        /** @var string */
36
        private $INPUT;
37
        /** @var array|null */
38
        private $PARSED_INPUT;
39

40
        public function __construct(
41
                array $server,
42
                array $get,
43
                array $post,
44
                array $files,
45
                array $cookie,
46
                array $HEADERS,
47
                string $INPUT
48
        ) {
49
                $this->server  = $server;
8✔
50
                $this->get     = $get;
8✔
51
                $this->post    = $post;
8✔
52
                $this->files   = $files;
8✔
53
                $this->cookie  = $cookie;
8✔
54
                $this->HEADERS = $HEADERS;
8✔
55
                $this->INPUT   = $INPUT;
8✔
56

57
                parse_str($INPUT, $PARSED_INPUT);
8✔
58
                $this->PARSED_INPUT = $PARSED_INPUT;
8✔
59

60
                if( !isset($server['REQUEST_URI']) ) {
8✔
61
                        throw new RuntimeException('REQUEST_URI not set');
×
62
                }
63

64
                if( !isset($server['REQUEST_METHOD']) ) {
8✔
65
                        throw new RuntimeException('REQUEST_METHOD not set');
×
66
                }
67

68
                $parsedUrl = parse_url($server['REQUEST_URI']);
8✔
69
                if( $parsedUrl === false ) {
8✔
NEW
70
                        throw new RuntimeException('Failed to parse REQUEST_URI: ' . $server['REQUEST_URI']);
×
71
                }
72

73
                $this->parsedUri = $parsedUrl;
8✔
74
        }
75

76
        /**
77
         * Specify data which should be serialized to JSON
78
         */
79
        public function jsonSerialize() : array {
80
                return [
2✔
81
                        self::JSON_KEY_GET          => $this->get,
2✔
82
                        self::JSON_KEY_POST         => $this->post,
2✔
83
                        self::JSON_KEY_FILES        => $this->files,
2✔
84
                        self::JSON_KEY_COOKIE       => $this->cookie,
2✔
85
                        self::JSON_KEY_HEADERS      => $this->HEADERS,
2✔
86
                        self::JSON_KEY_METHOD       => $this->getRequestMethod(),
2✔
87
                        self::JSON_KEY_INPUT        => $this->INPUT,
2✔
88
                        self::JSON_KEY_PARSED_INPUT => $this->PARSED_INPUT,
2✔
89
                        self::JSON_KEY_REQUEST_URI  => $this->getRequestUri(),
2✔
90

91
                        self::JSON_KEY_PARSED_REQUEST_URI => $this->parsedUri,
2✔
92
                ];
2✔
93
        }
94

95
        /**
96
         * @return array
97
         */
98
        public function getParsedUri() {
99
                return $this->parsedUri;
10✔
100
        }
101

102
        public function getRequestUri() : string {
103
                return $this->server['REQUEST_URI'];
6✔
104
        }
105

106
        public function getRequestMethod() : string {
107
                return $this->server['REQUEST_METHOD'];
5✔
108
        }
109

110
        public function getServer() : array {
111
                return $this->server;
3✔
112
        }
113

114
        public function getGet() : array {
115
                return $this->get;
3✔
116
        }
117

118
        public function getPost() : array {
119
                return $this->post;
1✔
120
        }
121

122
        public function getFiles() : array {
123
                return $this->files;
×
124
        }
125

126
        public function getCookie() : array {
127
                return $this->cookie;
3✔
128
        }
129

130
        public function getHeaders() : array {
131
                return $this->HEADERS;
3✔
132
        }
133

134
        public function getInput() : string {
135
                return $this->INPUT;
3✔
136
        }
137

138
        public function getParsedInput() : ?array {
139
                return $this->PARSED_INPUT;
3✔
140
        }
141

142
}
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