Completed
Push — develop ( 890a38...10c7b4 )
by Tom
03:27
created

BaseCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 5
c 3
b 0
f 1
lcom 0
cbo 0
dl 0
loc 58
ccs 23
cts 23
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A configure() 0 19 1
A getDefaultClient() 0 4 1
A getClient() 0 4 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->addArgument(
40 8
                'username',
41 8
                InputArgument::REQUIRED,
42 8
                'IBM Watson Service credentials username.'
43
            )
44 8
            ->addArgument(
45 8
                'password',
46 8
                InputArgument::REQUIRED,
47 8
                'IBM Watson Service credentials password.'
48
            )
49 8
            ->addOption(
50 8
                'version-date',
51 8
                '-d',
52 8
                InputOption::VALUE_REQUIRED,
53 8
                'API version date, defaults to current date i.e. latest release'
54
            );
55 8
    }
56
57
    /**
58
     * @return ClientInterface
59
     */
60 1
    public function getDefaultClient()
61
    {
62 1
        return new Client();
63
    }
64
65
    /**
66
     * @return ClientInterface
67
     */
68 1
    public function getClient()
69
    {
70 1
        return $this->client;
71
    }
72
}
73