Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
AbstractHandler | |
100.00% |
7 / 7 |
|
100.00% |
7 / 7 |
7 | |
100.00% |
1 / 1 |
hasResource | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getResource | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
hasUri | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getUri | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getHttpVersion | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getUriObject | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
resource | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
send | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
reset | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
disconnect | n/a |
0 / 0 |
n/a |
0 / 0 |
0 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Http\Client\Handler; |
15 | |
16 | use Pop\Http\Auth; |
17 | use Pop\Http\Client\Request; |
18 | use Pop\Http\Client\Response; |
19 | use Pop\Http\Uri; |
20 | |
21 | /** |
22 | * HTTP client handler interface |
23 | * |
24 | * @category Pop |
25 | * @package Pop\Http |
26 | * @author Nick Sagona, III <dev@nolainteractive.com> |
27 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
28 | * @license http://www.popphp.org/license New BSD License |
29 | * @version 5.2.0 |
30 | */ |
31 | abstract class AbstractHandler implements HandlerInterface |
32 | { |
33 | |
34 | /** |
35 | * URI string |
36 | * @var ?string |
37 | */ |
38 | protected ?string $uri = null; |
39 | |
40 | /** |
41 | * HTTP version |
42 | * @var string |
43 | */ |
44 | protected string $httpVersion = '1.1'; |
45 | |
46 | /** |
47 | * Client resource object |
48 | * @var mixed |
49 | */ |
50 | protected mixed $resource = null; |
51 | |
52 | /** |
53 | * Determine whether or not resource is available |
54 | * |
55 | * @return bool |
56 | */ |
57 | public function hasResource(): bool |
58 | { |
59 | return ($this->resource !== null); |
60 | } |
61 | |
62 | /** |
63 | * Get the resource |
64 | * |
65 | * @return mixed |
66 | */ |
67 | public function getResource(): mixed |
68 | { |
69 | return $this->resource; |
70 | } |
71 | |
72 | /** |
73 | * Determine whether or not there is a URI string |
74 | * |
75 | * @return bool |
76 | */ |
77 | public function hasUri(): bool |
78 | { |
79 | return ($this->uri !== null); |
80 | } |
81 | |
82 | /** |
83 | * Get the URI string |
84 | * |
85 | * @return ?string |
86 | */ |
87 | public function getUri(): ?string |
88 | { |
89 | return $this->uri; |
90 | } |
91 | |
92 | /** |
93 | * Get the URI string |
94 | * |
95 | * @return string |
96 | */ |
97 | public function getHttpVersion(): string |
98 | { |
99 | return $this->httpVersion; |
100 | } |
101 | |
102 | /** |
103 | * Get the URI as an object |
104 | * |
105 | * @return Uri |
106 | */ |
107 | public function getUriObject(): Uri |
108 | { |
109 | return new Uri($this->uri); |
110 | } |
111 | |
112 | /** |
113 | * Get the resource (alias method) |
114 | * |
115 | * @return mixed |
116 | */ |
117 | public function resource(): mixed |
118 | { |
119 | return $this->resource; |
120 | } |
121 | |
122 | /** |
123 | * Method to send the request |
124 | */ |
125 | abstract public function send(); |
126 | |
127 | /** |
128 | * Method to reset the handler |
129 | * |
130 | * @return AbstractHandler |
131 | */ |
132 | abstract public function reset(): AbstractHandler; |
133 | |
134 | /** |
135 | * Close the handler connection |
136 | * |
137 | * @return void |
138 | */ |
139 | abstract public function disconnect(): void; |
140 | |
141 | } |