Passed
Pull Request — master (#459)
by butschster
18:55
created

Exception   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A withLocation() 0 11 1
1
<?php
2
3
/**
4
 * This file is part of Spiral Framework package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Attributes\Internal;
13
14
/**
15
 * @internal Exception is an internal library class, please do not use it in your code.
16
 * @psalm-internal Spiral\Attributes
17
 */
18
final class Exception
19
{
20
    /**
21
     * @throws \ReflectionException
22
     */
23 6
    public static function withLocation(\Throwable $e, string $file, int $line): \Throwable
24
    {
25 6
        $fileProperty = new \ReflectionProperty($e, 'file');
26 6
        $fileProperty->setAccessible(true);
27 6
        $fileProperty->setValue($e, $file);
28
29 6
        $lineProperty = new \ReflectionProperty($e, 'line');
30 6
        $lineProperty->setAccessible(true);
31 6
        $lineProperty->setValue($e, $line);
32
33 6
        return $e;
34
    }
35
}
36