DebugAttributeBuilder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 20
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 12 2
1
<?php
2
3
namespace ArinaSystems\JsonResponse\Builders;
4
5
use Exception;
6
use Illuminate\Support\Arr;
7
8
class DebugAttributeBuilder extends Builder
9
{
10
    /**
11
     * Build a value of the exception attribute.
12
     *
13
     * @param  \Exception  $exception
14
     * @return mixed
15
     */
16
    public function build($exception)
17
    {
18
        if (! is_a($exception, Exception::class)) {
19
            return $exception;
20
        }
21
22
        return [
23
            'file'  => $exception->getFile(),
24
            'line'  => $exception->getLine(),
25
            'trace' => collect($exception->getTrace())->map(function ($trace) {
26
                return Arr::except($trace, ['args']);
27
            })->all(),
28
        ];
29
    }
30
}
31