Passed
Push — master ( 4b0a97...b58b05 )
by Sebastian
01:37
created

Application::silenceXDebug()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 3
nc 2
nop 0
crap 3
1
<?php
2
/**
3
 * This file is part of CaptainHook.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace CaptainHook\App\Console;
11
12
use CaptainHook\App\CH;
13
use Symfony\Component\Console\Application as SymfonyApplication;
14
15
/**
16
 * Class Application
17
 *
18
 * @package CaptainHook
19
 * @author  Sebastian Feldmann <[email protected]>
20
 * @link    https://github.com/captainhookphp/captainhook
21
 * @since   Class available since Release 0.9.0
22
 */
23
class Application extends SymfonyApplication
24
{
25
    /**
26
     * @var \CaptainHook\App\Config
27
     */
28
    protected $config;
29
30
    /**
31
     * @var string
32
     */
33
    private static $logo = '   .oooooo.                            .              o8o              
34
  d8P\'  `Y8b                         .o8              `"\'              
35
 888           .oooo.   oo.ooooo.  .o888oo  .oooo.   oooo  ooo. .oo.   
36
 888          `P  )88b   888\' `88b   888   `P  )88b  `888  `888P"Y88b  
37
 888           .oP"888   888   888   888    .oP"888   888   888   888  
38
 `88b    ooo  d8(  888   888   888   888 . d8(  888   888   888   888  
39
  `Y8bood8P\'  `Y888""8o  888bod8P\'   "888" `Y888""8o o888o o888o o888o 
40
                         888                                           
41
                        o888o
42
      
43
                         .ed"""" """$$$$be.                     
44
                       -"           ^""**$$$e.                  
45
                     ."                   \'$$$c                 
46
                    /                      "4$$b                
47
                   d  3                     $$$$                
48
                   $  *                   .$$$$$$               
49
                  .$  ^c           $$$$$e$$$$$$$$.              
50
                  d$L  4.         4$$$$$$$$$$$$$$b              
51
                  $$$$b ^ceeeee.  4$$ECL.F*$$$$$$$              
52
      e$""=.      $$$$P d$$$$F $ $$$$$$$$$- $$$$$$              
53
     z$$b. ^c     3$$$F "$$$$b   $"$$$$$$$  $$$$*"      .=""$c  
54
    4$$$$L   \     $$P"  "$$b   .$ $$$$$...e$$        .=  e$$$. 
55
    ^*$$$$$c  %..   *c    ..    $$ 3$$$$$$$$$$eF     zP  d$$$$$ 
56
      "**$$$ec   "\   %ce""    $$$  $$$$$$$$$$*    .r" =$$$$P"" 
57
            "*$b.  "c  *$e.    *** d$$$$$"L$$    .d"  e$$***"   
58
              ^*$$c ^$c $$$      4J$$$$$% $$$ .e*".eeP"         
59
                 "$$$$$$"\'$=e....$*$$**$cz$$" "..d$*"           
60
                   "*$$$  *=%4.$ L L$ P3$$$F $$$P"              
61
                      "$   "%*ebJLzb$e$$$$$b $P"                
62
                        %..      4$$$$$$$$$$ "                  
63
                         $$$e   z$$$$$$$$$$%                    
64
                          "*$c  "$$$$$$$P"                      
65
                           ."""*$$$$$$$$bc                      
66
                        .-"    .$***$$$"""*e.                   
67
                     .-"    .e$"     "*$c  ^*b.                 
68
              .=*""""    .e$*"          "*bc  "*$e..            
69
            .$"        .z*"               ^*$e.   "*****e.      
70
            $$ee$c   .d"                     "*$.        3.     
71
            ^*$E")$..$"                         *   .ee==d%     
72
               $.d$$$*                           *  J$$$e*      
73
                """""                             "$$$"
74
75
             ooooo   ooooo                     oooo        
76
             `888\'   `888\'                     `888        
77
              888     888   .ooooo.   .ooooo.   888  oooo  
78
              888ooooo888  d88\' `88b d88\' `88b  888 .8P\'   
79
              888     888  888   888 888   888  888888.    
80
              888     888  888   888 888   888  888 `88b.  
81
             o888o   o888o `Y8bod8P\' `Y8bod8P\' o888o o888o 
82
83
';
84
85
    /**
86
     * Input output interface
87
     *
88
     * @var \CaptainHook\App\Console\IO
89
     */
90
    protected $io;
91
92
    /**
93
     * Application constructor
94
     */
95 10
    public function __construct()
96
    {
97 10
        parent::__construct('CaptainHook', CH::VERSION);
98
99 10
        $this->setDefaultCommand('help');
100 10
        $this->silenceXDebug();
101 10
    }
102
103
    /**
104
     * Append release date to version output
105
     *
106
     * @return string
107
     */
108 2
    public function getLongVersion() : string
109
    {
110 2
        return sprintf(
111 2
            '<info>%s</info> version <comment>%s</comment> %s',
112 2
            $this->getName(),
113 2
            $this->getVersion(),
114 2
            CH::RELEASE_DATE
115
        );
116
    }
117
118
    /**
119
     * Prepend help with logo.
120
     *
121
     * @return string
122
     */
123 1
    public function getHelp() : string
124
    {
125 1
        return self::$logo . parent::getHelp();
126
    }
127
128
    /**
129
     * Make sure X-Debug does not interfere with the exception handling
130
     *
131
     * @return void
132
     */
133 10
    public function silenceXDebug(): void
134
    {
135 10
        if (function_exists('ini_set') && extension_loaded('xdebug')) {
136 10
            ini_set('xdebug.show_exception_trace', false);
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type string expected by parameter $newvalue of ini_set(). ( Ignorable by Annotation )

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

136
            ini_set('xdebug.show_exception_trace', /** @scrutinizer ignore-type */ false);
Loading history...
137 10
            ini_set('xdebug.scream', false);
138
        }
139 10
    }
140
}
141