PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / rmccue / requests / src / Exception / Http.php
ameliabooking / vendor / rmccue / requests / src / Exception Last commit date
Http 5 months ago Transport 5 months ago ArgumentCount.php 5 months ago Http.php 5 months ago InvalidArgument.php 5 months ago Transport.php 5 months ago
Http.php
79 lines
1 <?php
2 /**
3 * Exception based on HTTP response
4 *
5 * @package Requests\Exceptions
6 */
7
8 namespace AmeliaVendor\WpOrg\Requests\Exception;
9
10 use AmeliaVendor\WpOrg\Requests\Exception;
11 use AmeliaVendor\WpOrg\Requests\Exception\Http\StatusUnknown;
12
13 /**
14 * Exception based on HTTP response
15 *
16 * @package Requests\Exceptions
17 */
18 class Http extends Exception {
19 /**
20 * HTTP status code
21 *
22 * @var integer
23 */
24 protected $code = 0;
25
26 /**
27 * Reason phrase
28 *
29 * @var string
30 */
31 protected $reason = 'Unknown';
32
33 /**
34 * Create a new exception
35 *
36 * There is no mechanism to pass in the status code, as this is set by the
37 * subclass used. Reason phrases can vary, however.
38 *
39 * @param string|null $reason Reason phrase
40 * @param mixed $data Associated data
41 */
42 public function __construct($reason = null, $data = null) {
43 if ($reason !== null) {
44 $this->reason = $reason;
45 }
46
47 $message = sprintf('%d %s', $this->code, $this->reason);
48 parent::__construct($message, 'httpresponse', $data, $this->code);
49 }
50
51 /**
52 * Get the status message.
53 *
54 * @return string
55 */
56 public function getReason() {
57 return $this->reason;
58 }
59
60 /**
61 * Get the correct exception class for a given error code
62 *
63 * @param int|bool $code HTTP status code, or false if unavailable
64 * @return string Exception class name to use
65 */
66 public static function get_class($code) {
67 if (!$code) {
68 return StatusUnknown::class;
69 }
70
71 $class = sprintf('\AmeliaVendor\WpOrg\Requests\Exception\Http\Status%d', $code);
72 if (class_exists($class)) {
73 return $class;
74 }
75
76 return StatusUnknown::class;
77 }
78 }
79