Passed
Branch release/1.5.0 (5f009d)
by vincent
05:05
created

Catalog::getJobsList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * This file is part of the Tmdb package.
4
 *
5
 * (c) Vincent Faliès <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
11
 * @author Vincent Faliès <[email protected]>
12
 * @copyright Copyright (c) 2017
13
 */
14
15
16
namespace vfalies\tmdb;
17
18
use vfalies\tmdb\Catalogs\Genres;
19
use vfalies\tmdb\Catalogs\Jobs;
20
use vfalies\tmdb\Interfaces\TmdbInterface;
21
22
/**
23
 * Catalog class
24
 * @package Tmdb
25
 * @author Vincent Faliès <[email protected]>
26
 * @copyright Copyright (c) 2017
27
 */
28
class Catalog
29
{
30
    /**
31
     * Tmdb object
32
     * @var Tmdb
33
     */
34
    private $tmdb   = null;
35
    /**
36
     * Logger
37
     * @var LoggerInterface
38
     */
39
    private $logger = null;
40
41
    /**
42
     * Constructor
43
     * @param vfalies\tmdb\Interfaces\TmdbInterface $tmdb
44
     */
45 6
    public function __construct(TmdbInterface $tmdb)
46
    {
47 6
        $this->tmdb   = $tmdb;
0 ignored issues
show
Documentation Bug introduced by
$tmdb is of type object<vfalies\tmdb\Interfaces\TmdbInterface>, but the property $tmdb was declared to be of type object<vfalies\tmdb\Tmdb>. 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...
48 6
        $this->logger = $tmdb->logger;
0 ignored issues
show
Bug introduced by
Accessing logger on the interface vfalies\tmdb\Interfaces\TmdbInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
49 6
    }
50
51
    /**
52
     * Get movie genres list
53
     * @param array $options
54
     * @return \Generator
55
     */
56 3
    public function getMovieGenres(array $options = array())
57
    {
58 3
        $this->logger->debug('Starting getting movie genres');
59 3
        $catalog = new Genres($this->tmdb);
60 3
        return $catalog->getMovieList($options);
61
    }
62
63
    /**
64
     * Get TVShow genres list
65
     * @param array $options
66
     * @return \Generator
67
     */
68 2
    public function getTVShowGenres(array $options = array())
69
    {
70 2
        $this->logger->debug('Starting getting tv show genres');
71 2
        $catalog = new Genres($this->tmdb);
72 2
        return $catalog->getTVList($options);
73
    }
74
75
    /**
76
     * Get Job list
77
     * @param array $options
78
     * @return \Generator|\stdClass
79
     */
80 1
    public function getJobsList(array $options = array())
81
    {
82 1
        $this->logger->debug('Starting getting jobs list');
83 1
        $catalog = new Jobs($this->tmdb);
84 1
        return $catalog->getList($options);
85
    }
86
}
87