Completed
Push — develop ( 4ff741...64bd10 )
by Tom
14:53
created

BaseCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
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
9
/**
10
 * Class BaseCommand
11
 * @package Bobbyshaw\WatsonVisualRecognition\Commands
12
 */
13
abstract class BaseCommand extends Command
14
{
15
16
    /** @var Client|ClientInterface  */
17
    protected $client;
18
19
    /**
20
     * GetClassifiersCommand constructor.
21
     *
22
     * @param null|string $name
23
     * @param ClientInterface $client
24
     */
25
    public function __construct($name = null, ClientInterface $client = null)
26
    {
27
        $this->client = isset($client) ? $client : $this->getDefaultClient();
0 ignored issues
show
Documentation Bug introduced by
isset($client) ? $client...his->getDefaultClient() is of type object<Bobbyshaw\WatsonV...nition\ClientInterface>, but the property $client was declared to be of type object<Bobbyshaw\WatsonVisualRecognition\Client>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
28
29
        parent::__construct($name);
30
    }
31
32
    /**
33
     * @return Client
34
     */
35
    public function getDefaultClient()
36
    {
37
        return new Client();
38
    }
39
40
    /**
41
     * @return Client|ClientInterface
42
     */
43
    public function getClient()
44
    {
45
        return $this->client;
46
    }
47
}
48