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

BaseCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
ccs 15
cts 15
cp 1
rs 9.4285
cc 1
eloc 14
nc 1
nop 0
crap 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