Completed
Push — master ( 6366df...fbe022 )
by Kirill
23s queued 19s
created

Exception   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 20
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
     * @param \Throwable $e
22
     * @param string $file
23
     * @param int $line
24
     * @return \Throwable
25
     * @throws \ReflectionException
26
     */
27
    public static function withLocation(\Throwable $e, string $file, int $line): \Throwable
28
    {
29
        $fileProperty = new \ReflectionProperty($e, 'file');
30
        $fileProperty->setAccessible(true);
31
        $fileProperty->setValue($e, $file);
32
33
        $lineProperty = new \ReflectionProperty($e, 'line');
34
        $lineProperty->setAccessible(true);
35
        $lineProperty->setValue($e, $line);
36
37
        return $e;
38
    }
39
}
40