Completed
Push — master ( 4f2fad...dd1cd3 )
by Guillaume
07:10
created

MonitorApplicationConfig   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 9

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B configure() 0 43 1
1
<?php
2
3
namespace Hogosha\Monitor\Console;
4
5
use Hogosha\Monitor\Client\GuzzleClient;
6
use Hogosha\Monitor\Configuration\ConfigurationDumper;
7
use Hogosha\Monitor\Configuration\ConfigurationLoader;
8
use Hogosha\Monitor\Console\Handler\InitHandler;
9
use Hogosha\Monitor\Console\Handler\RunHandler;
10
use Hogosha\Monitor\Model\UrlProvider;
11
use Hogosha\Monitor\Monitor;
12
use Hogosha\Monitor\Runner\Runner;
13
use Webmozart\Console\Api\Args\Format\Option;
14
use Webmozart\Console\Config\DefaultApplicationConfig;
15
16
/**
17
 * @author Guillaume Cavana <[email protected]>
18
 */
19
class MonitorApplicationConfig extends DefaultApplicationConfig
20
{
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function configure()
26
    {
27
        parent::configure();
28
29
        $configurationLoader =  new ConfigurationLoader(
30
            rtrim(getcwd(), DIRECTORY_SEPARATOR),
31
            Monitor::CONFIG_FILENAME
32
        );
33
        $configurationDumper = new ConfigurationDumper();
34
35
        $runner = new Runner(
36
            new UrlProvider($configurationLoader),
37
            GuzzleClient::createClient()
38
        );
39
40
        $signature = <<<SIGNATURE
41
  _____                             _
42
 |_   _|                           | |
43
   | |  _ __ ___  _ __   __ _  __ _| |_ ___
44
   | | | '__/ _ \| '_ \ / _` |/ _` | __/ _ \
45
  _| |_| | | (_) | | | | (_| | (_| | ||  __/
46
 |_____|_|  \___/|_| |_|\__, |\__,_|\__\___|
47
                         __/ |
48
                        |___/
49
SIGNATURE;
50
51
        $this
52
            ->setDisplayName($signature."\n".'Irongate Monitor Application')
53
            ->setName('monitor')
54
            ->setVersion(Monitor::VERSION)
55
                ->beginCommand('init')
56
                    ->setDescription('Create a default configuration file if you do not have one')
57
                    ->setHandler(new InitHandler($configurationLoader, $configurationDumper))
0 ignored issues
show
Bug introduced by
The call to InitHandler::__construct() misses a required argument $filesystem.

This check looks for function calls that miss required arguments.

Loading history...
Documentation introduced by
new \Hogosha\Monitor\Con..., $configurationDumper) is of type object<Hogosha\Monitor\C...le\Handler\InitHandler>, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
58
                    ->setHelp('php <info>bin/monitor</info> init')
59
                ->end()
60
                ->beginCommand('run')
61
                    ->setDescription('Launch the monitor process')
62
                    ->setHandler(new RunHandler($runner))
63
                    ->setHelp('php <info>bin/monitor</info> init')
64
                    ->addOption('format', null, Option::OPTIONAL_VALUE, 'The formatter', 'table')
65
                ->end()
66
        ;
67
    }
68
}
69