Completed
Push — master ( 1f3fa8...7d4b61 )
by Mike
03:08
created

Application   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 45
rs 10
c 1
b 0
f 1
wmc 6
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getLongVersion() 0 18 1
A add() 0 8 3
A isPharContextAllowed() 0 4 2
1
<?php
2
3
namespace Sugarcrm\UpgradeSpec;
4
5
use League\HTMLToMarkdown\HtmlConverter;
6
use Sugarcrm\UpgradeSpec\Command\GenerateSpecCommand;
7
use Sugarcrm\UpgradeSpec\Command\PharContext;
8
use Sugarcrm\UpgradeSpec\Data\Manager;
9
use Sugarcrm\UpgradeSpec\Data\Provider\LocalUpgradePackage;
10
use Sugarcrm\UpgradeSpec\Data\Provider\SupportSugarcrm;
11
use Sugarcrm\UpgradeSpec\Data\ProviderChain;
12
use Sugarcrm\UpgradeSpec\Element\Generator as ElementGenerator;
13
use Sugarcrm\UpgradeSpec\Element\Provider;
14
use Sugarcrm\UpgradeSpec\Formatter\MarkdownFormatter;
15
use Sugarcrm\UpgradeSpec\Helper\File;
16
use Sugarcrm\UpgradeSpec\Helper\Sugarcrm;
17
use Sugarcrm\UpgradeSpec\Spec\Generator;
18
use Sugarcrm\UpgradeSpec\Template\TwigRenderer;
19
use Symfony\Component\Console\Application as BaseApplication;
20
use Symfony\Component\Console\Command\Command;
21
use Twig_Loader_Filesystem;
22
23
final class Application extends BaseApplication
24
{
25
    /**
26
     * Gets full version name.
27
     *
28
     * @return string
29
     */
30
    public function getLongVersion()
31
    {
32
        $art = <<<EOL
33
      ___            ___            ___          ___            ___     
34
     /__/\          /  /\          /  /\        /  /\          /  /\    
35
     \  \:\        /  /:/_        /  /::\      /  /:/_        /  /:/    
36
      \  \:\      /  /:/ /\      /  /:/\:\    /  /:/ /\      /  /:/     
37
  ___  \  \:\    /  /:/ /::\    /  /:/~/:/   /  /:/ /:/_    /  /:/  ___ 
38
 /__/\  \__\:\  /__/:/ /:/\:\  /__/:/ /:/   /__/:/ /:/ /\  /__/:/  /  /\
39
 \  \:\ /  /:/  \  \:\/:/~/:/  \  \:\/:/    \  \:\/:/ /:/  \  \:\ /  /:/
40
  \  \:\  /:/    \  \::/ /:/    \  \::/      \  \::/ /:/    \  \:\  /:/ 
41
   \  \:\/:/      \__\/ /:/      \  \:\       \  \:\/:/      \  \:\/:/  
42
    \  \::/         /__/:/        \  \:\       \  \::/        \  \::/   
43
     \__\/          \__\/          \__\/        \__\/          \__\/    
44
EOL;
45
46
        return sprintf('<info>%s</info>', $art) . PHP_EOL . PHP_EOL . parent::getLongVersion() . ' by <comment>Mike Kamornikov</comment> and <comment>Denis Stiblo</comment>';
47
    }
48
49
    public function add(Command $command)
50
    {
51
        if (($command instanceof PharContext) && !$this->isPharContextAllowed()) {
52
            return null;
53
        }
54
55
        return parent::add($command); // TODO: Change the autogenerated stub
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
56
    }
57
58
    /**
59
     * Defines if it's called from phar.
60
     *
61
     * @return bool
62
     */
63
    private function isPharContextAllowed()
64
    {
65
        return \Phar::running() || (bool) getenv('DEV_MODE');
66
    }
67
}
68