summaryrefslogtreecommitdiffstats
path: root/Twilio/Http/Response.php
blob: 242eef797e8d3b00693729205bc602a62e925bf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php


namespace Twilio\Http;


class Response {
    protected $headers;
    protected $content;
    protected $statusCode;

    public function __construct($statusCode, $content, $headers = array()) {
        $this->statusCode = $statusCode;
        $this->content = $content;
        $this->headers = $headers;
    }

    /**
     * @return mixed
     */
    public function getContent() {
        return json_decode($this->content, true);
    }

    /**
     * @return mixed
     */
    public function getStatusCode() {
        return $this->statusCode;
    }

    public function getHeaders() {
        return $this->headers;
    }

    public function ok() {
        return $this->getStatusCode() < 400;
    }

    public function __toString() {
        return '[Response] HTTP ' . $this->getStatusCode() . ' ' . $this->getContent();
    }
}