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 | /** |
||
77 | * Helper method responsible for constructing and returning {@see BadResponseError} exceptions. |
||
78 | * |
||
79 | * @param RequestInterface $request The faulty request |
||
80 | * @param ResponseInterface $response The error-filled response |
||
81 | * |
||
82 | * @return BadResponseError |
||
83 | */ |
||
84 | 2 | public function httpError(RequestInterface $request, ResponseInterface $response) |
|
109 | |||
110 | 2 | private function getStatusCodeMessage($statusCode) |
|
121 | |||
122 | /** |
||
123 | * Helper method responsible for constructing and returning {@see UserInputError} exceptions. |
||
124 | * |
||
125 | * @param string $expectedType The type that was expected from the user |
||
126 | * @param mixed $userValue The incorrect value the user actually provided |
||
127 | * @param string|null $furtherLink A link to further information if necessary (optional). |
||
128 | * |
||
129 | * @return UserInputError |
||
130 | */ |
||
131 | 2 | public function userInputError($expectedType, $userValue, $furtherLink = null) |
|
148 | } |
||
149 |