1
|
|
|
<?php namespace CodeZero\Curl; |
2
|
|
|
|
3
|
|
|
class ResponseInfo |
4
|
|
|
{ |
5
|
|
|
/** |
6
|
|
|
* Array Request Information |
7
|
|
|
* |
8
|
|
|
* @var array |
9
|
|
|
*/ |
10
|
|
|
private $info; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Constructor |
14
|
|
|
* |
15
|
|
|
* @param array $info |
16
|
|
|
*/ |
17
|
|
|
public function __construct(array $info) |
18
|
|
|
{ |
19
|
|
|
$this->info = $info; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function getUrl() |
23
|
|
|
{ |
24
|
|
|
return $this->fetchInfo('url'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function getContentType() |
28
|
|
|
{ |
29
|
|
|
return $this->fetchInfo('content_type'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function getHttpCode() |
33
|
|
|
{ |
34
|
|
|
return $this->fetchInfo('http_code'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function getHeaderSize() |
38
|
|
|
{ |
39
|
|
|
return $this->fetchInfo('header_size'); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function getCertInfo() |
43
|
|
|
{ |
44
|
|
|
return $this->fetchInfo('certinfo'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function getSslVerifyResult() |
48
|
|
|
{ |
49
|
|
|
return $this->fetchInfo('ssl_verify_result'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function getRedirectCount() |
53
|
|
|
{ |
54
|
|
|
return $this->fetchInfo('redirect_count'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function getTotalTime() |
58
|
|
|
{ |
59
|
|
|
return $this->fetchInfo('total_time'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getNameLookupTime() |
63
|
|
|
{ |
64
|
|
|
return $this->fetchInfo('namelookup_time'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function getConnectTime() |
68
|
|
|
{ |
69
|
|
|
return $this->fetchInfo('connect_time'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getPreTransferTime() |
73
|
|
|
{ |
74
|
|
|
return $this->fetchInfo('pretransfer_time'); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getStartTransferTime() |
78
|
|
|
{ |
79
|
|
|
return $this->fetchInfo('starttransfer_time'); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getRedirectTime() |
83
|
|
|
{ |
84
|
|
|
return $this->fetchInfo('redirect_time'); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function getFileTime() |
88
|
|
|
{ |
89
|
|
|
return $this->fetchInfo('filetime'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function getRequestSize() |
93
|
|
|
{ |
94
|
|
|
return $this->fetchInfo('request_size'); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function getDownloadSize() |
98
|
|
|
{ |
99
|
|
|
return $this->fetchInfo('size_download'); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function getDownloadContentLength() |
103
|
|
|
{ |
104
|
|
|
return $this->fetchInfo('download_content_length'); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function getDownloadSpeed() |
108
|
|
|
{ |
109
|
|
|
return $this->fetchInfo('speed_download'); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function getUploadSize() |
113
|
|
|
{ |
114
|
|
|
return $this->fetchInfo('size_upload'); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function getUploadContentLength() |
118
|
|
|
{ |
119
|
|
|
return $this->fetchInfo('upload_content_length'); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function getUploadSpeed() |
123
|
|
|
{ |
124
|
|
|
return $this->fetchInfo('speed_upload'); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Get the array with all of the request information |
129
|
|
|
* |
130
|
|
|
* @return array |
131
|
|
|
*/ |
132
|
|
|
public function getList() |
133
|
|
|
{ |
134
|
|
|
return $this->info; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Search the information array for the specified key and return the value |
139
|
|
|
* |
140
|
|
|
* @param string $key |
141
|
|
|
* |
142
|
|
|
* @return mixed |
143
|
|
|
*/ |
144
|
|
|
private function fetchInfo($key) |
145
|
|
|
{ |
146
|
|
|
return array_key_exists($key, $this->info) |
147
|
|
|
? $this->info[$key] |
148
|
|
|
: null; |
149
|
|
|
} |
150
|
|
|
} |
151
|
|
|
|