DebugAttributeBuilder::build()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 12
rs 10
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