Passed
Push — master ( 19eefc...9f50d2 )
by Shiyu
02:25
created

Dumps::failure()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 11
rs 10
1
<?php
2
/**
3
 * Dumps (failure)
4
 * User: moyo
5
 * Date: Jul 25, 2019
6
 * Time: 11:06
7
 */
8
9
namespace Carno\Console\Chips;
10
11
use Symfony\Component\Console\Input\ArgvInput;
12
use Symfony\Component\Console\Output\ConsoleOutput;
13
use Symfony\Component\Console\Style\SymfonyStyle;
14
use Throwable;
15
16
trait Dumps
17
{
18
    /**
19
     * @param Throwable $e
20
     * @param int $c
21
     */
22
    protected function failure(Throwable $e, int $c = null) : void
23
    {
24
        $styled = (new SymfonyStyle(new ArgvInput(), new ConsoleOutput()));
25
26
        $styled->title(get_class($e));
27
        $styled->error($e->getMessage());
28
        $styled->note(sprintf('%s:%d', $e->getFile(), $e->getLine()));
29
30
        dump($e);
31
32
        is_null($c) || exit($c);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
33
    }
34
}
35