Completed
Push — master ( 9e80ab...1774f3 )
by Sebastian
04:55 queued 01:14
created

ExceptionToJsonRenderer::toJson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
namespace Kartenmacherei\RestFramework\Exception;
3
4
class ExceptionToJsonRenderer
5
{
6
    /**
7
     * @param \Throwable $throwable
8
     * @return string
9
     */
10
    public function toJson(\Throwable $throwable): string
11
    {
12
        return json_encode(
13
            [
14
                'class' => get_class($throwable),
15
                'message' => $throwable->getMessage(),
16
                'file' => $throwable->getFile(),
17
                'line' => $throwable->getLine()
18
            ]
19
        );
20
    }
21
}
22