Completed
Push — master ( 98a062...441031 )
by Ryan
10:10
created

ViewDisplayer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A display() 0 10 1
A canDisplay() 0 4 1
1
<?php namespace Anomaly\Streams\Platform\Exception\Displayer;
2
3
use Illuminate\Http\Response;
4
5
/**
6
 * Class ViewDisplayer
7
 *
8
 * @link   http://pyrocms.com/
9
 * @author PyroCMS, Inc. <[email protected]>
10
 * @author Ryan Thompson <[email protected]>
11
 */
12
class ViewDisplayer extends \GrahamCampbell\Exceptions\Displayers\ViewDisplayer
13
{
14
15
    /**
16
     * Get the error response associated with the given exception.
17
     *
18
     * @param \Exception $exception
19
     * @param string     $id
20
     * @param int        $code
21
     * @param string[]   $headers
22
     *
23
     * @return \Symfony\Component\HttpFoundation\Response
24
     */
25
    public function display(\Exception $exception, $id, $code, array $headers)
26
    {
27
        $info = $this->info->generate($exception, $id, $code);
28
29
        return new Response(
30
            $this->factory->make("streams::errors/{$code}", $info),
31
            $code,
32
            array_merge($headers, ['Content-Type' => $this->contentType()])
33
        );
34
    }
35
36
    /**
37
     * Can we display the exception?
38
     *
39
     * @param \Exception $original
40
     * @param \Exception $transformed
41
     * @param int        $code
42
     *
43
     * @return bool
44
     */
45
    public function canDisplay(\Exception $original, \Exception $transformed, $code)
46
    {
47
        return $this->factory->exists("streams::errors/{$code}");
48
    }
49
}
50