Skip to content

Commit 9e58c7f

Browse files
authored
Extracted interfaces (#2)
1 parent 26bd495 commit 9e58c7f

8 files changed

+265
-153
lines changed

composer.json

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"require-dev": {
3232
"phpunit/phpunit": "^4.8 || ^5.0",
3333
"squizlabs/php_codesniffer": "^2.0"
34-
3534
},
3635
"autoload": {
3736
"psr-4": {

src/Curl.php

+16-53
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
namespace PHPCurl\CurlWrapper;
33

4-
class Curl
4+
class Curl implements CurlInterface
55
{
66
/**
77
* @var resource
@@ -17,51 +17,39 @@ public function __construct($url = null)
1717
}
1818

1919
/**
20-
* @see curl_init()
21-
*
22-
* @param string $url URL
23-
* @return void
20+
* @inheritdoc
2421
*/
2522
public function init($url = null)
2623
{
2724
$this->handle = curl_init($url);
2825
}
2926

3027
/**
31-
* @see curl_errno()
32-
*
33-
* @return int
28+
* @inheritdoc
3429
*/
3530
public function errno()
3631
{
3732
return curl_errno($this->handle);
3833
}
3934

4035
/**
41-
* @see curl_error()
42-
*
43-
* @return string
36+
* @inheritdoc
4437
*/
4538
public function error()
4639
{
4740
return curl_error($this->handle);
4841
}
4942

5043
/**
51-
* @see curl_exec()
52-
*
53-
* @return boolean|string
44+
* @inheritdoc
5445
*/
5546
public function exec()
5647
{
5748
return curl_exec($this->handle);
5849
}
5950

6051
/**
61-
* @see curl_getinfo()
62-
*
63-
* @param int $opt CURLINFO_*
64-
* @return array|string
52+
* @inheritdoc
6553
*/
6654
public function getInfo($opt = 0)
6755
{
@@ -72,96 +60,71 @@ public function getInfo($opt = 0)
7260
}
7361

7462
/**
75-
* @see curl_setopt()
76-
*
77-
* @param int $option Option code
78-
* @param mixed $value Option value
79-
* @return boolean
63+
* @inheritdoc
8064
*/
8165
public function setOpt($option, $value)
8266
{
8367
return curl_setopt($this->handle, $option, $value);
8468
}
8569

8670
/**
87-
* @see curl_setopt_array()
88-
*
89-
* @param array $options Options
90-
* @return boolean
71+
* @inheritdoc
9172
*/
9273
public function setOptArray(array $options)
9374
{
9475
return curl_setopt_array($this->handle, $options);
9576
}
9677

9778
/**
98-
* @see curl_version()
99-
*
100-
* @param int $age
101-
* @return array
79+
* @inheritdoc
10280
*/
10381
public function version($age = CURLVERSION_NOW)
10482
{
10583
return curl_version($age);
10684
}
10785

10886
/**
109-
* @see curl_strerror()
110-
*
111-
* @param int $errornum
112-
* @return string
87+
* @inheritdoc
11388
*/
11489
public function strError($errornum)
11590
{
11691
return curl_strerror($errornum);
11792
}
11893

11994
/**
120-
* @see curl_escape()
121-
*
122-
* @param string $str
123-
* @return string
95+
* @inheritdoc
12496
*/
12597
public function escape($str)
12698
{
12799
return curl_escape($this->handle, $str);
128100
}
129101

130102
/**
131-
* @see curl_unescape()
132-
*
133-
* @param string $str
134-
* @return string
103+
* @inheritdoc
135104
*/
136105
public function unescape($str)
137106
{
138107
return curl_unescape($this->handle, $str);
139108
}
140109

141110
/**
142-
* @see curl_reset()
143-
*
144-
* @return void
111+
* @inheritdoc
145112
*/
146113
public function reset()
147114
{
148115
curl_reset($this->handle);
149116
}
117+
150118
/**
151-
* @see curl_pause()
152-
*
153-
* @param int $bitmask
154-
* @return int
119+
* @inheritdoc
155120
*/
156121
public function pause($bitmask)
157122
{
158123
return curl_pause($this->handle, $bitmask);
159124
}
160125

161126
/**
162-
* Get curl handle
163-
*
164-
* @return resource
127+
* @inheritdoc
165128
*/
166129
public function getHandle()
167130
{

src/CurlInterface.php

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
namespace PHPCurl\CurlWrapper;
3+
4+
interface CurlInterface
5+
{
6+
/**
7+
* @see curl_init()
8+
*
9+
* @param string $url URL
10+
* @return void
11+
*/
12+
public function init($url = null);
13+
14+
/**
15+
* @see curl_errno()
16+
*
17+
* @return int
18+
*/
19+
public function errno();
20+
21+
/**
22+
* @see curl_error()
23+
*
24+
* @return string
25+
*/
26+
public function error();
27+
28+
/**
29+
* @see curl_exec()
30+
*
31+
* @return boolean|string
32+
*/
33+
public function exec();
34+
35+
/**
36+
* @see curl_getinfo()
37+
*
38+
* @param int $opt CURLINFO_*
39+
* @return array|string
40+
*/
41+
public function getInfo($opt = 0);
42+
43+
/**
44+
* @see curl_setopt()
45+
*
46+
* @param int $option Option code
47+
* @param mixed $value Option value
48+
* @return boolean
49+
*/
50+
public function setOpt($option, $value);
51+
52+
/**
53+
* @see curl_setopt_array()
54+
*
55+
* @param array $options Options
56+
* @return boolean
57+
*/
58+
public function setOptArray(array $options);
59+
60+
/**
61+
* @see curl_version()
62+
*
63+
* @param int $age
64+
* @return array
65+
*/
66+
public function version($age = CURLVERSION_NOW);
67+
68+
/**
69+
* @see curl_strerror()
70+
*
71+
* @param int $errornum
72+
* @return string
73+
*/
74+
public function strError($errornum);
75+
76+
/**
77+
* @see curl_escape()
78+
*
79+
* @param string $str
80+
* @return string
81+
*/
82+
public function escape($str);
83+
84+
/**
85+
* @see curl_unescape()
86+
*
87+
* @param string $str
88+
* @return string
89+
*/
90+
public function unescape($str);
91+
92+
/**
93+
* @see curl_reset()
94+
*
95+
* @return void
96+
*/
97+
public function reset();
98+
99+
/**
100+
* @see curl_pause()
101+
*
102+
* @param int $bitmask
103+
* @return int
104+
*/
105+
public function pause($bitmask);
106+
107+
/**
108+
* Get curl handle
109+
*
110+
* @return resource
111+
*/
112+
public function getHandle();
113+
}

0 commit comments

Comments
 (0)