Passed
Branch account (733a83)
by vincent
02:35
created

GeneratorTrait::searchItemGenerator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
crap 2
1
<?php declare(strict_types=1);
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
 * @author Vincent Faliès <[email protected]>
11
 * @copyright Copyright (c) 2017
12
 */
13
14
namespace VfacTmdb\Traits;
15
16
/**
17
 * Generator trait
18
 * @package Tmdb
19
 * @author Vincent Faliès <[email protected]>
20
 * @copyright Copyright (c) 2017
21
 */
22
trait GeneratorTrait
23
{
24
    /**
25
     * Item generator method
26
     * @param array $results
27
     * @param string $class
28
     */
29 35
    protected function searchItemGenerator(array $results, string $class)
30
    {
31 35
        $this->logger->debug('Starting search item generator', array('results' => $results, 'class' => $class));
0 ignored issues
show
Bug introduced by
The property logger does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
32 35
        foreach ($results as $result) {
33 32
            $element = new $class($this->tmdb, $result);
0 ignored issues
show
Bug introduced by
The property tmdb does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
34
35 32
            yield $element;
36
        }
37 10
    }
38
}
39