AUTO FILTER

@param mixed $item
@return mixed
764824
private function _autoFilter($item)
	{
		# NULL
		if(null === $item) { return null; }

		# WHAT ELSE
		if(is_object($item) || is_resource($item)) {
			return $item;
		}

		# BOOL
		if(is_bool($item) || $item === 'false' || $item === 'true') {
			if($item === 'false') { $item = false; }
			elseif($item === 'true') { $item = true; }
			return $item;
		}

		# ARRAY
		if(is_array($item)) {
			foreach ($item as $k => $v) {
				$item[$k] = $this->_autoFilter($v);
			}
			return $item;
		}

		# INT
		$int = filter_var($item, FILTER_VALIDATE_INT);
		if($int !== false) { return $int; }

		# FLOAT
		if(preg_match('#^([\+\-])?(?!0[0-9]+)[0-9]+\.[0-9]+$#', $item)) {
			return floatval($item);
		}

		# STRING
		return filter_var($item, FILTER_SANITIZE_SPECIAL_CHARS);
	}
274782
public function get($item)
    {
        $data = $this->getData();

        return empty($data->$item) ? null : $data->$item;
    }
1113113
public function add(Item $item)
    {
        foreach ($this->filters as $filter) {
            $this->applyFilter($filter, $item);
        }

        $this->items[] = $item;

        return $this;
    }
1073029
public function auto_filter($filter = true)
	{
		if (func_num_args() == 0)
		{
			return $this->auto_filter;
		}

		$this->auto_filter = $filter;

		return $this;
	}
951039
protected function recursiveToArray($item)
    {
        if (is_array($item)) {

            foreach ($item as &$subitem) {
                $subitem = $this->recursiveToArray($subitem);
            }

            unset($subitem);

            return $item;
        }

        if ($item instanceof Arrayable) {
            return $item->toArray();
        }

        return $item;
    }
1256520
public function fillAction(Item $item)
    {
        // do fill
        $this->get('anime_db.item_folder_filler.filler_folder')->fillFolder($item);

        return $this->render('AnimeDbItemFolderFillerBundle:Filler:fill.html.twig', [
            'item' => $item
        ]);
    }
363542
protected function filter(\SplFileInfo $item) : bool
    {
        $filename = $item->getFilename();

        if (!$this->includeHidden && $filename{0} == '.') {
            return false;
        }

        if ($this->includeNames) {
            if (!in_array($filename, $this->includeNames, true)) {
                return false;
            }
        }
        elseif ($this->excludeNames && in_array($filename, $this->excludeNames, true)) {
            return false;
        }

        if ($this->includeExtensions) {
            if (!$this->longExtensions) {
                if (!in_array($item->getExtension(), $this->includeExtensions, true)) {
                    return false;
                }
            } else {
                $matches = false;
                foreach ($this->includeExtensions as $ext) {
                    if (
                        ($pos = strpos($filename, '.' . $ext)) !== false
                        && $pos == strlen($filename) - strlen($ext) - 1
                    ) {
                        $matches = true;
                        break;
                    }
                }
                if (!$matches) {
                    return false;
                }
            }
        }
        elseif ($this->excludeExtensions) {
            if (!$this->longExtensions) {
                if (in_array($item->getExtension(), $this->excludeExtensions, true)) {
                    return false;
                }
            } else {
                foreach ($this->excludeExtensions as $ext) {
                    if (
                        ($pos = strpos($filename, '.' . $ext)) !== false
                        && $pos == strlen($filename) - strlen($ext) - 1
                    ) {
                        return false;
                    }
                }
            }
        }

        if ($this->includeParents || $this->excludeParents) {
            $parent_path = $item->getPathname();
            $parent_path = substr($parent_path, 0, -strlen($filename) - 1);
            if ($this->includeParents) {
                if ($parent_path === false) {
                    // No space for any parent path.
                    return false;
                }
                $matches = false;
                foreach ($this->includeParents as $name) {
                    if (
                        ($pos = strpos($parent_path, '/' . $name)) !== false
                        && $pos == strlen($parent_path) - strlen($name) - 1
                    ) {
                        $matches = true;
                        break;
                    }
                }
                if (!$matches) {
                    return false;
                }
            }
            elseif ($parent_path !== false) {
                foreach ($this->excludeParents as $name) {
                    if (
                        ($pos = strpos($parent_path, '/' . $name)) !== false
                        && $pos == strlen($parent_path) - strlen($name) - 1
                    ) {
                        return false;
                    }
                }
            }
        }

        if ($this->customFilter) {
            return call_user_func_array($this->customFilter, [$item]);
        }

        return true;
    }
796817
public function automaticItemType($data)
	{
		if (isset($data['item_type']))
		{
			$data['item_type'] = strtolower(preg_replace("/[^a-zA-Z0-9\-]/", '', trim($data['item_type'])));
		}

		return $data['item_type'];
	}
165048
public function contains( $item ) {
			
			for ( $i=0; $i < $this->len; $i++ ) {
			
				if ( $this->compare( $item, $this->items[$i] ) === 0 ) {
			
					return true;
			
				}
			
			}

			return false;
		}
1317546
public function getSourceForFill(Item $item)
    {
        /* @var $source Source */
        foreach ($item->getSources() as $source) {
            if (strpos($source->getUrl(), $this->browser->getHost()) === 0) {
                return $source->getUrl();
            }
        }

        return '';
    }
966024
public function itemCreate(Item $item)
    {
        $response = $this->getGuzzleClient()
            ->post(
                '/items',
                array_merge($this->setQuery(), $this->setBody($item))
            );

        return $this->serializer->deserialize(
            $response->getBody()->getContents(),
            Item::class,
            'json'
        );
    }
996732
protected function checkType($item)
    {
        $type = $this->getItemType($item);
        if (! $this->type) {
            $this->type = $type;

            return true;
        }

        if ($this->type != $type) {
            return false;
        }

        return true;
    }
1238379
public function removeStyle(Item $item)
    {
        $item->setIntro(preg_replace('/(<[^>]+) style=".*?"/i', '$1', $item->getIntro()));
        $item->setContent(preg_replace('/(<[^>]+) style=".*?"/i', '$1', $item->getContent()));

        return $item;
    }
1210196
public function auto_filter($setting = null)
	{
		if (func_num_args() == 0)
		{
			return $this->_view->auto_filter();
		}

		return $this->_view->auto_filter($setting);
	}
1236317
private function getUsage($item)
    {
        return $this->getCacheItem(self::CACHE_USAGE, $item, function () {
            return $this->getContext()->invokeApiGet('SHOW_USER_USAGE', ['user' => $this->getUsername()]);
        });
    }
739229
protected function recursiveClone($item)
    {
        if (is_object($item)) {
            return clone $item;
        } elseif (is_array($item)) {
            return array_map([$this, 'recursiveClone'], $item);
        }
        return $item;
    }
735498
public function removeItem(Item $item)
    {
        if ($this->items->contains($item)) {
            $this->items->removeElement($item);
            $item->removeGenre($this);
        }

        return $this;
    }