Passed
Push — features/scrutinizer_conf ( cf2d4a...45dfb6 )
by Nicolas
01:09
created

WanInfosCommand::execute()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 26
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 12
nc 2
nop 2
dl 0
loc 26
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: nicolas
5
 * Date: 05/02/17
6
 * Time: 14:32
7
 */
8
namespace Devgiants\Command;
9
10
use Buzz\Message\Request;
0 ignored issues
show
Bug introduced by
The type Buzz\Message\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Devgiants\Model\ApplicationCommand;
12
use Devgiants\Configuration\ConfigurationManager;
13
use Devgiants\Configuration\ApplicationConfiguration as AppConf;
14
use Pimple\Container;
0 ignored issues
show
Bug introduced by
The type Pimple\Container was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Symfony\Component\Console\Input\InputInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Input\InputInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Symfony\Component\Console\Output\OutputInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Output\OutputInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
18
class WanInfosCommand extends ApplicationCommand
19
{
20
	/**
21
	 * Wan command constructor.
22
	 *
23
	 * @param null|string $name
24
	 * @param Container $container
25
	 */
26
	public function __construct( $name, Container $container ) {
27
		parent::__construct( $name, $container );
28
	}
29
30
    /**
31
     * @inheritdoc
32
     */
33
    protected function configure()
34
    {
35
        $this
36
            ->setName('wan:infos')
37
            ->setDescription('Read WAN infos')
38
            ->setHelp("This command allows you to read livebox WAN infos")
39
        ;
40
41
        parent::configure();
42
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47
    protected function execute(InputInterface $input, OutputInterface $output)
48
    {
49
50
	    $ymlFile = $this->getConfigurationFile( $input );
51
52
	    if ( $ymlFile !== NULL && is_file( $ymlFile ) ) {
53
54
		    // Structures check and configuration loading
55
		    $configurationManager = new ConfigurationManager( $ymlFile );
56
		    $configuration        = $configurationManager->load();
57
58
59
		    // Execute request
60
		    $response = $this->tools->createRequest(
61
			    Request::METHOD_POST,
62
			    "{$configuration[ AppConf::HOST[ AppConf::NODE_NAME ] ]}/ws",
63
			    [
64
				    "service"    => "NMC",
65
				    "method"     => "getWANStatus",
66
				    "parameters" => [],
67
			    ]
68
		    );
69
		    $output->write($response->getContent() );
70
71
		    // Handle post command stuff
72
		    parent::execute( $input, $output );
73
	    }
74
    }
75
}