DomainException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

1 Method

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