Passed
Push — master ( b674ac...2bc77e )
by Kirill
04:21
created

Exception   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A withLocation() 0 11 1
1
<?php
2
3
/**
4
 * This file is part of Attributes 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
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
}