Exception::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
ccs 0
cts 0
cp 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Exception;
6
7
use Stringable;
8
9
/**
10
 * Represents an exception that's caused by some DB-related operations.
11
 *
12
 * It provides more information about the error that's caused by the exception.
13
 */
14
class Exception extends \Exception implements Stringable
15
{
16
    public function __construct(string $message, public array|null $errorInfo = [], \Exception $previous = null)
17
    {
18 261
        parent::__construct($message, 0, $previous);
19
    }
20 261
21 261
    /**
22 261
     * @return string Readable representation of exception.
23
     */
24
    public function __toString(): string
25
    {
26
        return parent::__toString() . PHP_EOL . 'Additional Information:' . PHP_EOL . print_r($this->errorInfo, true);
0 ignored issues
show
Bug introduced by
Are you sure print_r($this->errorInfo, true) of type string|true can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
        return parent::__toString() . PHP_EOL . 'Additional Information:' . PHP_EOL . /** @scrutinizer ignore-type */ print_r($this->errorInfo, true);
Loading history...
27 5
    }
28
}
29