Process multi search items

@param  array                                                    $item
@return bool|Movie|Person|Person\CastMember|Person\CrewMember|Tv
@throws \RuntimeException
763519
private function processSearchMultiItem(array $item)
    {
        if (array_key_exists('media_type', $item)) {
            switch ($item['media_type']) {
                case 'movie':
                    return $this->getMovieFactory()->create($item);
                case 'tv':
                    return $this->getTvFactory()->create($item);
                case 'person':
                    return $this->getPeopleFactory()->create($item);
                default:
                    throw new \RuntimeException(sprintf(
                        'Could not process media_type "%s" in multi search, type unknown.',
                        $item['media_type']
                    ));
            }
        }

        return false;
    }
606932
private function findItem($item, $arr, $key) {
        for($j = 0; $j < count($arr); $j++) {
            if($arr[$j]->$key == $item->$key) {
                return $j;
            }
        }
        return false;
    }
880565
public static function cast(\Cawa\Orm\Collection $item, array $a)
    {
        return [
            Caster::PREFIX_VIRTUAL . 'count' => $item->count(),
        ] + $a;
    }
608691
protected function processItems(array $items)
    {
        $processedItems = [];

        foreach ($items as $entry) {
            if (isset($entry['metadata']) && is_array($entry['metadata'])) {
                $processedItems[] = new SearchResult($entry);
            }
        }

        $this->items = new ModelCollection($processedItems);
    }
24702
public function process(array $items)
    {
        if (!$this->limit) {
            return $items;
        }
        $total = count($items);
        if ($this->limit > $total) {
            return $items;
        }
        for ($i = $this->limit; $i < $total; $i++) {
            if (isset($items[$i])) {
                unset($items[$i]);
            }
        }

        return $items;
    }
992926
public function getCatalogItem(array $item)
    {
        $sources = [$this->browser->getHost().$item['url']];
        if (!empty($item['world_art_id'])) {
            $sources[] = str_replace('#ID#', $item['world_art_id'], self::WORLD_ART_URL);
        }
        if (!empty($item['myanimelist_id'])) {
            $sources[] = str_replace('#ID#', $item['myanimelist_id'], self::MY_ANIME_LIST_URL);
        }
        if (!empty($item['ani_db_id'])) {
            $sources[] = str_replace('#ID#', $item['ani_db_id'], self::ANI_DB_URL);
        }
        /* @var $source \AnimeDb\Bundle\CatalogBundle\Entity\Source|null */
        $source = $this->repository->findOneBy(['url' => $sources]);
        if ($source instanceof Source) {
            return $source->getItem();
        }
        return null;
    }
1010956
public function submitItem($identifier, $item)
    {
        $job = $this->getJobFromId($identifier);
        if ($job === null) {
            throw new \RuntimeException(
                "The identifier does not exist: $identifier"
            );
        }
        $idNum = $job->id();
        return $this->processor->submit($item, $idNum);
    }
1137675
protected function _serializeToArray($item)
    {
        $result = array();

        if (is($item, 'AnDomainBehaviorSerializable')) {
            $result = $item->toSerializableArray();
        } else {
            $result = (array) $item;
        }

        return $result;
    }
1016651
public function add($item)
    {
        if (is_array($item)) {
            return array_map([$this, 'add'], $item);
        }

        if (! $item | strlen(trim($item)) === 0) {
            return false;
        }

        $this->collection[] = trim(strip_tags($item));
    }
105569
public function getRow($item)
	{
		$row = [];

		foreach ($this->columns as $column) {
			$row[] = strip_tags($column->render($item));
		}

		return $row;
	}
1143659
public function process(array $items)
    {
        $total = count($items);
        for ($i = 1; $i < $total; $i++) {
            for ($j = 0; $j < $total - $i; $j++) {
                if (!$items[$j]->getDate() || !$items[$j + 1]->getDate()) {
                    continue;
                }
                if ($items[$j]->getDate()->getTimestamp() > $items[$j + 1]->getDate()->getTimestamp()) {
                    continue;
                }
                $aux = $items[$j + 1];
                $items[$j + 1] = $items[$j];
                $items[$j] = $aux;
            }
        }

        return $items;
    }
940291
public static function includeInArray($item, $array)
    {
        if (self::isItemOrderInvalid($item, $array)) {
            return array_merge($array, [$item['name'] => $item['content']]);
        }

        $count = 0;
        $last  = $array;
        $first = [];
        foreach ($array as $key => $value) {
            if ($count == $item['order']) {
                return array_merge($first, [$item['name'] => $item['content']], $last);
            }

            unset($last[$key]);
            $first[$key] = $value;

            $count++;
        }
    }
1198220
final public function compare($item1, $item2)
    {
        if (!$this->isReady()) {
            throw new \RuntimeException("The comparer is not ready, no valid callback has been set.");
        }

        return call_user_func_array($this->callback, [$item1, $item2, $this->options]);
    }
1124795
public function isArray($item=null) {
    list($item) = self::_wrapArgs(func_get_args(), 1);
    return self::_wrap(is_array($item));
  }
466230
public function merge(array $item)
    {
        $this->title = $this->getValue('title', $item, $this->getTitle());
        $this->description = $this->getValue('description', $item, $this->getDescription());
        $this->moreText = $this->getValue('moreText', $item, $this->getMoreText());
        $this->url = $this->getValue('url', $item, $this->getUrl());
        $this->mediaId = $this->getValue('mediaId', $item, $this->getMediaId());

        return $this;
    }
82604
public function process(array $row)
    {
        foreach ($row as &$item) {
            if (is_bool($item)) {
                $item = $item ? 1 : 0;
            }
        }

        return $row;
    }
930911
private function pushStream($item)
    {
        $id = uniqid('STREAM_' . mt_rand(), true) . '_';
        $this->streams[$id] = $item; // push
        $this->hash[] = $id;
        $item = $id;

        return $item;
    }