Check accept mimetype

@since   1.1
@param   string $mimetype Test mimetype.
@return  bool True if test is ok else false.
356164
public function isAcceptMimetype($mimetype)
    {
        if ($this->hasHeader('Accept')) {
            return $this->isAccept($this->getHeader('Accept'), $mimetype);
        }
        return false;
    }
54992
protected function stripMimeTypeParameters($mimeType)
    {
        $mimeType = explode(';', $mimeType);
        $mimeType = trim(array_shift($mimeType));

        return $mimeType;
    }
1249486
public static function isValidOpType(string $opType = null): bool
    {
        return \in_array($opType, self::$opTypes, true);
    }
123134
function mimeTypeFilters( $mimeData )
    {
        if ( $this->hasMIMETypeSetting( $mimeData ) )
        {
            $settings = $this->mimeTypeSetting( $mimeData );
            if ( $settings )
            {
                return $settings['extra_filters'];
            }
        }
        return false;
    }
1194716
public function setMimeType($mimeType) {
        if (isset(self::$mimeTypeMapping[$mimeType])) {
            // The mime type has a mapping, use that instead
            $mimeType = self::$mimeTypeMapping[$mimeType];
        }

        $this->mimeType = $mimeType;

        return $this;
    }
314948
public function isImage($mimeType)
    {
        $isValid = false;

        $allowedType = array('image/jpeg' , 'image/png' ,'image/gif');

        if (\in_array($mimeType, $allowedType)) {
            $isValid = true;
        }

        return $isValid;
    }
590941
protected function mime_in_header($mime, $accept_header)
	{
		// make sure we have input
		if (empty($mime) or empty($accept_header))
		{
			// no header or no mime to check
			return true;
		}

		// process the accept header and get a list of accepted mimes
		$accept_mimes = array();
		$accept_header = explode(',', $accept_header);
		foreach ($accept_header as $accept_def)
		{
			$accept_def = explode(';', $accept_def);
			$accept_def = trim($accept_def[0]);
			if ( ! in_array($accept_def, $accept_mimes))
			{
				$accept_mimes[] = $accept_def;
			}
		}

		// match on generic mime type
		if (in_array('*/*', $accept_mimes))
		{
			return true;
		}

		// match on full mime type
		if (in_array($mime, $accept_mimes))
		{
			return true;
		}

		// match on generic mime type
		$mime = substr($mime, 0, strpos($mime, '/')).'/*';
		if (in_array($mime, $accept_mimes))
		{
			return true;
		}

		// no match
		return false;
	}
218326
public function getMimetypeFromExtension($extension)
    {
        $extension = strtolower($extension);

        return isset($this->mimetypes[$extension])
            ? $this->mimetypes[$extension]
            : parent::getMimetypeFromExtension($extension);
    }
1321607
public function is($type)
    {
        $myMimetype = $this->getMimetype();

        if (strpos($type, '/')) {
            return strtolower($myMimetype) == strtolower($type);
        }

        $prefix = strtolower(explode('/', $myMimetype)[0]);

        return strtolower($type) == $prefix;
    }
838913
public static function provideDefaultClassFor(string $mimeType): bool
    {
        if (in_array($mimeType, array_keys(self::$supported))) {
            return true;
        }

        if (class_exists('stubbles\xml\serializer\XmlSerializerFacade') && in_array($mimeType, array_keys(self::$xml))) {
            return true;
        }

        if (class_exists('stubbles\img\Image') && in_array($mimeType, array_keys(self::$image))) {
            return true;
        }

        return false;
    }
1062283
private function getNotAcceptableHttpException(string $accept, array $mimeTypes = null): NotAcceptableHttpException
    {
        if (null === $mimeTypes) {
            $mimeTypes = array_keys($this->mimeTypes);
        }

        return new NotAcceptableHttpException(sprintf(
            'Requested format "%s" is not supported. Supported MIME types are "%s".',
            $accept,
            implode('", "', $mimeTypes)
        ));
    }
961338
public static function isValidType($type)
    {
        if ($type === '') {
            $result = true;
        } else {
            $valid = self::getTypesInfo();
            $result = isset($valid[$type]);
        }

        return $result;
    }
20491
public static function for_mimetypes($mimetypes)
    {
        foreach ($mimetypes as $mimetype) {
            if ($formatter = self::for_mimetype($mimetype)) {
                return $formatter;
            }
        }

        return false;
    }
1145160
def _is_ctype(self, ctype):
        """"""
        if not self.valid:
            return False
        mime = self.content_type
        return self.ContentMimetypes.get(mime) == ctype
26831
public function setMIMEType(string $mimetype)
    {
        if ($this->discoverInterface()) {
            $this->nb_interface->setMIMEType($mimetype);
        } else {
            throw new ENabuRenderException(
                ENabuRenderException::ERROR_RENDER_NOT_FOUND,
                array($this->nb_descriptor->getKey())
            );
        }

        return $this;
    }
565967
protected function isMimetypeAllowed($filename, $default = "")
    {
        $numAllowed = sizeof($this->allowedMimeTypes);
        $numDenied = sizeof($this->deniedMimeTypes);

        if ($numAllowed == 0 && $numDenied == 0) {
            return true;
        }

        /**
         * Try to retrieve the mime type of the file
         */
        // first, try as an image. May cause exception if not an image, so do not trigger errors
        if (@($data = getimagesize($filename))) {
            $mimetype = $data['mime'];
        } else {
            if (function_exists('finfo_open') && function_exists('finfo_file')) {
                $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
                $mimetype = finfo_file($finfo, $filename);
                finfo_close($finfo);
            } else {
                // this is deprecated
                $mimetype = function_exists('mime_content_type') ? mime_content_type($filename) : $default;
            }
        }

        // validate the mime type agains the white and blacklists
        if ($numAllowed > 0 && !in_array($mimetype, $this->allowedMimeTypes)) {
            return false;
        }
        if ($numDenied > 0 && in_array($mimetype, $this->deniedMimeTypes)) {
            return false;
        }

        return true;
    }
816542
public function setMimeType(string $mime_type) {
        if(!$this->setModified('mime_type', $mime_type)->isModified()) {
            return $this;
        }
		$this->mime_type = $mime_type;
		return $this;
    }