Skip to content

Commit 4821557

Browse files
author
Martin Brecht-Precht
committed
Refactored a lot.
Implemented the basic Curl handling.
1 parent 245ee0b commit 4821557

15 files changed

+658
-51
lines changed

src/BasicHttpClient.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace BasicHttpClient;
44

5+
use BasicHttpClient\Request\Base\RequestInterface;
56
use BasicHttpClient\Request\Request;
67

78
class BasicHttpClient
89
{
910

1011
/**
11-
* @var Request
12+
* @var RequestInterface
1213
*/
1314
private $request;
1415

src/Request/Authentication/Base/AuthenticationInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
namespace BasicHttpClient\Request\Authentication\Base;
44

5+
use BasicHttpClient\Request\Base\CurlConfiguratorInterface;
6+
57
/**
68
* Interface AuthenticationInterface
79
*
810
* @package BasicHttpClient\Request\Authentication\Base
911
*/
10-
interface AuthenticationInterface
12+
interface AuthenticationInterface extends CurlConfiguratorInterface
1113
{
1214

1315
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace BasicHttpClient\Request\Base;
4+
5+
/**
6+
* Interface CurlConfiguratorInterface
7+
*
8+
* @package BasicHttpClient\Request\Base
9+
*/
10+
interface CurlConfiguratorInterface
11+
{
12+
13+
/**
14+
* @param resource $curl
15+
* @return $this
16+
*/
17+
public function configureCurl($curl);
18+
19+
}

src/Request/Base/RequestInterface.php

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
3+
namespace BasicHttpClient\Request\Base;
4+
5+
use BasicHttpClient\Request\Authentication\Base\AuthenticationInterface;
6+
use BasicHttpClient\Request\Message\Base\MessageInterface;
7+
use BasicHttpClient\Request\Transport\Base\TransportInterface;
8+
9+
/**
10+
* Class Request
11+
*
12+
* @package BasicHttpClient\Request
13+
*/
14+
interface RequestInterface extends CurlConfiguratorInterface
15+
{
16+
17+
/**
18+
* @return string
19+
*/
20+
public function getEndpoint();
21+
22+
/**
23+
* @param string $endpoint
24+
* @return $this
25+
*/
26+
public function setEndpoint($endpoint);
27+
28+
/**
29+
* @return int
30+
*/
31+
public function getPort();
32+
33+
/**
34+
* @param int $port
35+
* @return $this
36+
*/
37+
public function setPort($port);
38+
39+
/**
40+
* @return string
41+
*/
42+
public function getMethod();
43+
44+
/**
45+
* @param string $method
46+
* @return $this
47+
*/
48+
public function setMethod($method);
49+
50+
/**
51+
* @return TransportInterface
52+
*/
53+
public function getTransport();
54+
55+
/**
56+
* @param TransportInterface $transport
57+
* @return $this
58+
*/
59+
public function setTransport(TransportInterface $transport);
60+
61+
/**
62+
* @return MessageInterface
63+
*/
64+
public function getMessage();
65+
66+
/**
67+
* @param MessageInterface $message
68+
* @return $this
69+
*/
70+
public function setMessage(MessageInterface $message);
71+
72+
/**
73+
* @return AuthenticationInterface[]
74+
*/
75+
public function getAuthentications();
76+
77+
/**
78+
* @param AuthenticationInterface[] $authentications
79+
* @return $this
80+
*/
81+
public function setAuthentications(array $authentications);
82+
83+
/**
84+
* @param AuthenticationInterface $authentication
85+
* @return $this
86+
*/
87+
public function addAuthentication(AuthenticationInterface $authentication);
88+
89+
/**
90+
* @param AuthenticationInterface $authentication
91+
* @return $this
92+
*/
93+
public function removeAuthentication(AuthenticationInterface $authentication);
94+
95+
/**
96+
* @param AuthenticationInterface $authentication
97+
* @return bool
98+
*/
99+
public function hasAuthentication(AuthenticationInterface $authentication);
100+
101+
/**
102+
* @return bool
103+
*/
104+
public function hasAuthentications();
105+
106+
/**
107+
* @return int
108+
*/
109+
public function countAuthentications();
110+
111+
}
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
<?php
2+
3+
namespace BasicHttpClient\Request\Message\Base;
4+
5+
use BasicHttpClient\Request\Base\CurlConfiguratorInterface;
6+
use BasicHttpClient\Request\Message\Body\Base\BodyInterface;
7+
use BasicHttpClient\Request\Message\Cookie\Base\CookieInterface;
8+
use BasicHttpClient\Request\Message\Header\Base\HeaderInterface;
9+
10+
/**
11+
* Interface MessageInterface
12+
*
13+
* @package BasicHttpClient\Request\Message\Base
14+
*/
15+
interface MessageInterface extends CurlConfiguratorInterface
16+
{
17+
18+
/**
19+
* @return HeaderInterface[]
20+
*/
21+
public function getHeaders();
22+
23+
/**
24+
* @param string $name
25+
* @return HeaderInterface[]
26+
*/
27+
public function getHeadersByName($name);
28+
29+
/**
30+
* @param string $name
31+
* @return HeaderInterface
32+
*/
33+
public function getHeaderByName($name);
34+
35+
/**
36+
* @return $this
37+
*/
38+
public function clearHeaders();
39+
40+
/**
41+
* @param HeaderInterface[] $headers
42+
* @return $this
43+
*/
44+
public function setHeaders(array $headers);
45+
46+
/**
47+
* @param HeaderInterface $header
48+
* @return $this
49+
*/
50+
public function addAdditionalHeader(HeaderInterface $header);
51+
52+
/**
53+
* @param HeaderInterface $header
54+
* @return $this
55+
*/
56+
public function addHeader(HeaderInterface $header);
57+
58+
/**
59+
* @param string $name
60+
* @return $this
61+
*/
62+
public function removeHeadersByName($name);
63+
64+
/**
65+
* @param HeaderInterface $header
66+
* @return $this
67+
*/
68+
public function removeHeader(HeaderInterface $header);
69+
70+
/**
71+
* @param $name
72+
* @return bool
73+
*/
74+
public function hasHeaderWithName($name);
75+
76+
/**
77+
* @param HeaderInterface $header
78+
* @return bool
79+
*/
80+
public function hasHeader(HeaderInterface $header);
81+
82+
/**
83+
* @return bool
84+
*/
85+
public function hasHeaders();
86+
87+
/**
88+
* @return int
89+
*/
90+
public function getHeaderCount();
91+
92+
/**
93+
* @return CookieInterface[]
94+
*/
95+
public function getCookies();
96+
97+
/**
98+
* @param $name
99+
* @return CookieInterface
100+
*/
101+
public function getCookieByName($name);
102+
103+
/**
104+
* @return $this
105+
*/
106+
public function clearCookies();
107+
108+
/**
109+
* @param CookieInterface[] $cookies
110+
* @return $this
111+
*/
112+
public function setCookies($cookies);
113+
114+
/**
115+
* @param CookieInterface $cookie
116+
* @return $this
117+
*/
118+
public function addCookie(CookieInterface $cookie);
119+
120+
/**
121+
* @param string $name
122+
* @return $this
123+
*/
124+
public function removeCookieByName($name);
125+
126+
/**
127+
* @param CookieInterface $cookie
128+
* @return $this
129+
*/
130+
public function removeCookie(CookieInterface $cookie);
131+
132+
/**
133+
* @param $name
134+
* @return bool
135+
*/
136+
public function hasCookieWithName($name);
137+
138+
/**
139+
* @param CookieInterface $cookie
140+
* @return bool
141+
*/
142+
public function hasCookie(CookieInterface $cookie);
143+
144+
/**
145+
* @return bool
146+
*/
147+
public function hasCookies();
148+
149+
/**
150+
* @return int
151+
*/
152+
public function getCookieCount();
153+
154+
/**
155+
* @return BodyInterface
156+
*/
157+
public function getBody();
158+
159+
/**
160+
* @param BodyInterface $body
161+
* @return $this
162+
*/
163+
public function setBody(BodyInterface $body);
164+
165+
/**
166+
* @return bool
167+
*/
168+
public function hasBody();
169+
170+
/**
171+
* @return $this
172+
*/
173+
public function removeBody();
174+
175+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace BasicHttpClient\Request\Message\Cookie\Base;
4+
5+
/**
6+
* Class Cookie
7+
*
8+
* @package BasicHttpClient\Request\Message\Cookie
9+
*/
10+
interface CookieInterface
11+
{
12+
13+
/**
14+
* Cookie constructor.
15+
*
16+
* @param string $name
17+
* @param string $value
18+
*/
19+
public function __construct($name, $value);
20+
21+
/**
22+
* @return string
23+
*/
24+
public function getName();
25+
26+
/**
27+
* @param string $name
28+
* @return $this
29+
*/
30+
public function setName($name);
31+
32+
/**
33+
* @return string
34+
*/
35+
public function getValue();
36+
37+
/**
38+
* @param string $value
39+
* @return $this
40+
*/
41+
public function setValue($value);
42+
43+
}

0 commit comments

Comments
 (0)