BaseCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 5
c 4
b 0
f 1
lcom 0
cbo 0
dl 0
loc 59
ccs 24
cts 24
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A getDefaultClient() 0 4 1
A getClient() 0 4 1
A configure() 0 20 1
1
<?php
2
3
namespace Bobbyshaw\WatsonVisualRecognition\Commands;
4
5
use Bobbyshaw\WatsonVisualRecognition\Client;
6
use Bobbyshaw\WatsonVisualRecognition\ClientInterface;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputOption;
10
11
/**
12
 * Class BaseCommand
13
 * @package Bobbyshaw\WatsonVisualRecognition\Commands
14
 */
15
abstract class BaseCommand extends Command
16
{
17
18
    /** @var ClientInterface  */
19
    protected $client;
20
21
    /**
22
     * GetClassifiersCommand constructor.
23
     *
24
     * @param null|string $name
25
     * @param ClientInterface $client
26
     */
27 8
    public function __construct($name = null, ClientInterface $client = null)
28
    {
29 8
        $this->client = isset($client) ? $client : $this->getDefaultClient();
30
31 8
        parent::__construct($name);
32 8
    }
33
34
    /**
35
     * Configure command
36
     */
37 8
    protected function configure()
38
    {
39 8
        $this
40 8
            ->addArgument(
41 8
                'username',
42 8
                InputArgument::REQUIRED,
43
                'IBM Watson Service credentials username.'
44 8
            )
45 8
            ->addArgument(
46 8
                'password',
47 8
                InputArgument::REQUIRED,
48
                'IBM Watson Service credentials password.'
49 8
            )
50 8
            ->addOption(
51 8
                'version-date',
52 8
                '-d',
53 8
                InputOption::VALUE_REQUIRED,
54
                'API version date, defaults to current date i.e. latest release'
55 8
            );
56 8
    }
57
58
    /**
59
     * @return ClientInterface
60
     */
61 1
    public function getDefaultClient()
62
    {
63 1
        return new Client();
64
    }
65
66
    /**
67
     * @return ClientInterface
68
     */
69 1
    public function getClient()
70
    {
71 1
        return $this->client;
72
    }
73
}
74