Completed
Push — master ( 83b55d...472d84 )
by Justin
03:47 queued 36s
created

Response   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 10
eloc 20
dl 0
loc 50
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getOccurrenceUrl() 0 9 3
A getUuid() 0 3 1
A __toString() 0 6 1
A getInfo() 0 3 1
A __construct() 0 5 1
A wasSuccessful() 0 3 2
A getStatus() 0 3 1
1
<?php namespace Rollbar;
2
3
class Response
4
{
5
    private $status;
6
    private $info;
7
    private $uuid;
8
9
    public function __construct($status, $info, $uuid = null)
10
    {
11
        $this->status = $status;
12
        $this->info = $info;
13
        $this->uuid = $uuid;
14
    }
15
16
    public function getStatus()
17
    {
18
        return $this->status;
19
    }
20
21
    public function getInfo()
22
    {
23
        return $this->info;
24
    }
25
26
    public function getUuid()
27
    {
28
        return $this->uuid;
29
    }
30
31
    public function wasSuccessful()
32
    {
33
        return $this->status >= 200 && $this->status < 300;
34
    }
35
36
    public function getOccurrenceUrl()
37
    {
38
        if (is_null($this->uuid)) {
39
            return null;
40
        }
41
        if (!$this->wasSuccessful()) {
42
            return null;
43
        }
44
        return "https://rollbar.com/occurrence/uuid/?uuid=" . $this->uuid;
45
    }
46
47
    public function __toString()
48
    {
49
        $url = $this->getOccurrenceUrl();
50
        return "Status: $this->status\n" .
51
               "Body: " . json_encode($this->info) . "\n" .
52
               "URL: $url";
53
    }
54
}
55