1 | <?php |
||
20 | class Builder |
||
21 | { |
||
22 | /** |
||
23 | * The default domain to use for further link documentation. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | private $docDomain = 'http://docs.php-opencloud.com/en/latest/'; |
||
28 | |||
29 | /** |
||
30 | * The HTTP client required to validate the further links. |
||
31 | * |
||
32 | * @var ClientInterface |
||
33 | */ |
||
34 | private $client; |
||
35 | |||
36 | /** |
||
37 | * @param ClientInterface $client |
||
38 | */ |
||
39 | 2 | public function __construct(ClientInterface $client = null) |
|
40 | { |
||
41 | 2 | $this->client = $client ?: new Client(); |
|
42 | 2 | } |
|
43 | |||
44 | /** |
||
45 | * Internal method used when outputting headers in the error description. |
||
46 | * |
||
47 | * @param $name |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | 4 | private function header($name) |
|
55 | |||
56 | /** |
||
57 | * Before outputting custom links, it is validated to ensure that the user is not |
||
58 | * directed off to a broken link. If a 404 is detected, it is hidden. |
||
59 | * |
||
60 | * @param $link The proposed link |
||
61 | * |
||
62 | * @return bool |
||
63 | */ |
||
64 | 2 | private function linkIsValid($link) |
|
75 | |||
76 | private function str(MessageInterface $message) |
||
101 | 2 | ||
102 | /** |
||
103 | 2 | * Helper method responsible for constructing and returning {@see BadResponseError} exceptions. |
|
104 | 2 | * |
|
105 | 2 | * @param RequestInterface $request The faulty request |
|
106 | * @param ResponseInterface $response The error-filled response |
||
107 | 2 | * |
|
108 | * @return BadResponseError |
||
109 | */ |
||
110 | 2 | public function httpError(RequestInterface $request, ResponseInterface $response) |
|
135 | 2 | ||
136 | 2 | private function getStatusCodeMessage($statusCode) |
|
147 | |||
148 | /** |
||
149 | * Helper method responsible for constructing and returning {@see UserInputError} exceptions. |
||
150 | * |
||
151 | * @param string $expectedType The type that was expected from the user |
||
152 | * @param mixed $userValue The incorrect value the user actually provided |
||
153 | * @param string|null $furtherLink A link to further information if necessary (optional). |
||
154 | * |
||
155 | * @return UserInputError |
||
156 | */ |
||
157 | public function userInputError($expectedType, $userValue, $furtherLink = null) |
||
174 | } |
||
175 |