for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
/**
* This file is part of the Tmdb package.
*
* (c) Vincent Faliès <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* @author Vincent Faliès <[email protected]>
* @copyright Copyright (c) 2017
*/
namespace VfacTmdb\Traits;
use VfacTmdb\Interfaces\TmdbInterface;
* Generator trait
* @package Tmdb
trait GeneratorTrait
{
* GeneratorTrait object variable
* @var \stdClass
protected $generator_trait;
* Set GeneratorTrait variable
* @param TmdbInterface $tmdb
* @return void
protected function setGeneratorTrait(TmdbInterface $tmdb) : void
$this->generator_trait = new \stdClass();
$this->generator_trait->tmdb = $tmdb;
$this->generator_trait->logger = $tmdb->getLogger();
}
* Item generator method
* @param array $results
* @param string $class
protected function searchItemGenerator(array $results, string $class)
$this->generator_trait->logger->debug('Starting search item generator', array('results' => $results, 'class' => $class));
foreach ($results as $result) {
$element = new $class($this->generator_trait->tmdb, $result);
yield $element;