Passed
Push — master ( 4eed2e...471128 )
by Alexander
03:23
created

DebugHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 26
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerEditor() 0 7 2
A initDebug() 0 3 1
1
<?php 
2
3
/**
4
 * Lenevor Framework
5
 *
6
 * LICENSE
7
 *
8
 * This source file is subject to the new BSD license that is bundled
9
 * with this package in the file license.md.
10
 * It is also available through the world-wide-web at this URL:
11
 * https://lenevor.com/license
12
 * If you did not receive a copy of the license and are unable to
13
 * obtain it through the world-wide-web, please send an email
14
 * to [email protected] so we can send you a copy immediately.
15
 *
16
 * @package     Lenevor
17
 * @subpackage  Base
18
 * @link        https://lenevor.com
19
 * @copyright   Copyright (c) 2019 - 2023 Alexander Campo <[email protected]>
20
 * @license     https://opensource.org/licenses/BSD-3-Clause New BSD license or see https://lenevor.com/license or see /license.md
21
 */
22
23
namespace Syscodes\Components\Core\Exceptions\Debugging;
24
25
use Syscodes\Components\Debug\Handlers\PleasingPageHandler;
26
27
/**
28
 * Creates a new Debug PleasingPagehandler instance.
29
 */
30
class DebugHandler
31
{
32
    /**
33
     * Create a new Debug handler for debug mode.
34
     * 
35
     * @return \Syscodes\Components\Debug\Handlers\PleasingPageHandler
36
     */
37
    public function initDebug()
38
    {
39
        return take(new PleasingPageHandler, fn ($handler) => $this->registerEditor($handler));
0 ignored issues
show
Bug Best Practice introduced by
The expression return take(new Syscodes...ion(...) { /* ... */ }) also could return the type Syscodes\Components\Support\HigherOrderTakeProxy which is incompatible with the documented return type Syscodes\Components\Debu...ers\PleasingPageHandler.
Loading history...
40
    }
41
42
    /**
43
     * Register the editor with the handler.
44
     *
45
     * @param  \Syscodes\Components\Debug\Handlers\PleasingPageHandler $handler
46
     * 
47
     * @return static
48
     */
49
    protected function registerEditor($handler): static
50
    {
51
        if (config('app.editor', false)) {
52
            $handler->setEditor(config('app.editor'));
0 ignored issues
show
Bug introduced by
It seems like config('app.editor') can also be of type Syscodes\Components\Config\Configure; however, parameter $editor of Syscodes\Components\Debu...ageHandler::setEditor() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

52
            $handler->setEditor(/** @scrutinizer ignore-type */ config('app.editor'));
Loading history...
53
        }
54
55
        return $this;
56
    }
57
}