Completed
Push — master ( c1abc1...1c17fb )
by Josef
03:52
created

TwitchSDKException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 6
nc 2
nop 3
1
<?php
2
3
namespace jofner\SDK\TwitchTV;
4
5
/**
6
 * TwitchSDKException for TwitchTV API SDK for PHP
7
 *
8
 * PHP SDK for interacting with the TwitchTV API
9
 *
10
 * @author Josef Ohnheiser <[email protected]>
11
 * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT
12
 * @homepage https://github.com/jofner/Twitch-SDK
13
 */
14
class TwitchSDKException extends \Exception
15
{
16
    /** @var TwitchSDKException */
17
    protected $previous;
18
19
    public function __construct($message = null, $code = 0, TwitchSDKException $previous = null)
20
    {
21
        $this->code = $code;
22
        if ($message !== null) {
23
            $this->message = $message;
24
        }
25
        $this->previous = $previous;
26
27
        parent::__construct($this->message, $this->code, $this->previous);
28
    }
29
30
    /**
31
     * Formatted string for display
32
     * @return  string
33
     */
34
    public function __toString()
35
    {
36
        return __CLASS__ . ': [' . $this->code . ']: ' . $this->message;
37
    }
38
}
39