Passed
Push — master ( 59c59c...91bfb1 )
by Alan
02:13
created

Exception   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 20
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A setLocation() 0 8 2
1
<?php
2
3
namespace FigTree\Exceptions;
4
5
use Exception as PHPException;
6
use FigTree\Exceptions\Concerns\HasSeverity;
7
use FigTree\Exceptions\Contracts\{
8
	SevereExceptionInterface,
9
	LocatableExceptionInterface,
10
};
11
12
class Exception extends PHPException implements SevereExceptionInterface, LocatableExceptionInterface
13
{
14
	use HasSeverity;
15
16
	/**
17
	 * If required, set the file and line where the Exception was thrown.
18
	 *
19
	 * @param string $file
20
	 * @param int $line
21
	 *
22
	 * @return $this
23
	 */
24
	public function setLocation(string $file, int $line): LocatableExceptionInterface
25
	{
26
		if (file_exists($file)) {
27
			$this->file = $file;
28
			$this->line = max(0, $line);
29
		}
30
31
		return $this;
32
	}
33
}
34