public function getBestFormat($accept, $supported)
    {
        // Parse the accept header
        $parts = $this->parseHeader($accept);

        // Sort the array based on
        $parts = $this->sortParts($parts);

        // Loop through the array
        foreach ($parts as $part) {
            // Check if mime type is $supported
            if (in_array($part['value'], $supported)) {
                // Return the mime type
                return $part;
            }

            // Match for example image/*
            if (substr($part['value'], -2) === '/*') {
                // Get the type
                $range = substr($part['value'], 0, -2);

                // Look if type is found in $supported
                foreach ($supported as $support) {
                    if (strpos($support, $range, 0) === 0) {
                        $part['value'] = $support;
                        return $part;
                    }
                }
            }

            // Check if accepts anything
            if ($part['value'] === '*/*') {
                return $this->acceptsAnything($part['quality'], $supported);
            }
        }

        // Return null if no match is found
        return null;
    }