Exception::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 16
rs 9.2
cc 4
eloc 8
nc 8
nop 3
1
<?php
2
3
/*
4
 * This file is part of the Rutube PHP API Client package.
5
 *
6
 * (c) Rutube
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Rutube\Exceptions;
13
14
/**
15
 * Class Exception
16
 * @package Rutube\Exceptions
17
 */
18
class Exception extends \Exception
19
{
20
    /**
21
     * @param string $message
22
     * @param int $code
23
     * @param Exception $previous
24
     */
25
    public function __construct($message = '', $code = 0, Exception $previous = null)
26
    {
27
        if (is_object($message)) {
28
            $message = (array)$message;
29
        }
30
31
        if (is_array($message)) {
32
            $message = json_encode($message);
33
        }
34
35
        if (empty($message)) {
36
            $message = $this->message;
37
        }
38
39
        parent::__construct($message, $code, $previous);
40
    }
41
}
42