Completed
Branch dev (20d83f)
by Arina
01:20
created

DebugAttributeBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 14 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