Total Complexity | 4 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
27 | class ApiResponse |
||
28 | { |
||
29 | /** |
||
30 | * |
||
31 | * @access protected |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $curlResponse; |
||
35 | |||
36 | /** |
||
37 | * Constructor |
||
38 | * |
||
39 | * @access public |
||
40 | * @param string $plaintext AbuseIPDB response in plaintext |
||
41 | * |
||
42 | */ |
||
43 | public function __construct(?string $plaintext = null) |
||
44 | { |
||
45 | $this->curlResponse = $plaintext; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Get response as array. May return null |
||
50 | * |
||
51 | * @access public |
||
52 | * |
||
53 | * @return array|null |
||
54 | */ |
||
55 | public function getArray(): ?array |
||
56 | { |
||
57 | return json_decode($this->curlResponse, true); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Get response as object. May return null |
||
62 | * |
||
63 | * @access public |
||
64 | * |
||
65 | * @return object|null |
||
66 | */ |
||
67 | public function getObject(): ?object |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Get response as plaintext. May return null |
||
74 | * |
||
75 | * @access public |
||
76 | * |
||
77 | * @return string|null |
||
78 | */ |
||
79 | public function getPlaintext(): ?string |
||
82 | } |
||
83 | } |