1 | <?php |
||
5 | abstract class Connection |
||
6 | { |
||
7 | /** |
||
8 | * URL to execute |
||
9 | * |
||
10 | * @var $url |
||
11 | */ |
||
12 | public $url; |
||
13 | |||
14 | /** |
||
15 | * Contains curl_init() if success |
||
16 | * |
||
17 | * @var $init |
||
18 | */ |
||
19 | protected $init = false; |
||
20 | |||
21 | /** |
||
22 | * Additional cURL options |
||
23 | * |
||
24 | * @var $options |
||
25 | */ |
||
26 | public $options = []; |
||
27 | |||
28 | /** |
||
29 | * @var $header |
||
30 | */ |
||
31 | public $header = []; |
||
32 | |||
33 | /** |
||
34 | * @var $content |
||
35 | */ |
||
36 | public $content; |
||
37 | |||
38 | /** |
||
39 | * @param string $url Store URL |
||
40 | */ |
||
41 | 1 | function __construct($url) |
|
49 | |||
50 | /** |
||
51 | * Set additional curl_setopt_array() options |
||
52 | * |
||
53 | * @param array $options cURL Options |
||
54 | * @see http://php.net/manual/en/function.curl-setopt.php |
||
55 | * @return array |
||
56 | */ |
||
57 | public function setOptions($options = []) |
||
61 | |||
62 | /** |
||
63 | * Running the curl session |
||
64 | * |
||
65 | * @return void |
||
66 | */ |
||
67 | 1 | public function connection() |
|
81 | |||
82 | /** |
||
83 | * Get result of both header and content from curl |
||
84 | * |
||
85 | * @return array |
||
86 | */ |
||
87 | public function result() |
||
95 | |||
96 | /** |
||
97 | * Set cURL options |
||
98 | * |
||
99 | * @return array |
||
100 | */ |
||
101 | 1 | protected function options() |
|
110 | |||
111 | /** |
||
112 | * Validate URL and start cURL session; |
||
113 | * |
||
114 | * @param string $url Store URL |
||
115 | */ |
||
116 | 1 | protected function init($url) |
|
133 | } |
||
134 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.