BackendHandler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A error() 0 5 1
A renderException() 0 13 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: sheldon
5
 * Date: 18-3-27
6
 * Time: 下午5:30.
7
 */
8
9
namespace Yeelight\Exceptions;
10
11
use Illuminate\Support\MessageBag;
12
use Illuminate\Support\ViewErrorBag;
13
14
class BackendHandler
15
{
16
    /**
17
     * Render exception.
18
     *
19
     * @param \Exception $exception
20
     *
21
     * @return string
22
     */
23
    public static function renderException(\Exception $exception)
24
    {
25
        $error = new MessageBag([
26
            'type'    => get_class($exception),
27
            'message' => $exception->getMessage(),
28
            'file'    => $exception->getFile(),
29
            'line'    => $exception->getLine(),
30
        ]);
31
32
        $errors = new ViewErrorBag();
33
        $errors->put('exception', $error);
34
35
        return view('backend.partials.exception', compact('errors'))->render();
0 ignored issues
show
Bug introduced by
The method render() does not exist on Illuminate\Contracts\View\Factory. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        return view('backend.partials.exception', compact('errors'))->/** @scrutinizer ignore-call */ render();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
    }
37
38
    /**
39
     * Flash a error message to content.
40
     *
41
     * @param string $title
42
     * @param string $message
43
     *
44
     * @return mixed
45
     */
46
    public static function error($title = '', $message = '')
47
    {
48
        $error = new MessageBag(compact('title', 'message'));
49
50
        return session()->flash('error', $error);
51
    }
52
}
53