SyntaxErrorException::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
nc 3
nop 3
dl 0
loc 7
rs 10
c 4
b 0
f 0
1
<?php
2
3
namespace yentu\exceptions;
4
5
/**
6
 * Reports syntax errors in migration scripts with an attempt to show the actual line where error ocurred.
7
 */
8
class SyntaxErrorException extends YentuException {
9
10
    public function __construct(string $message, string $homePath, ?array $trace = null)
11
    {
12
        parent::__construct($message);
13
        foreach ($trace ?? $this->getTrace() as $item) {
14
            if (realpath($homePath . DIRECTORY_SEPARATOR . "migrations") === dirname($item['file'] ?? '')) {
15
                $this->message = "On line {$item['line']} of {$item['file']}: {$this->message}";
16
                break;
17
            }
18
        }
19
    }
20
}
21