public function preferred(array $types): ?string
    {
        if (empty($types)) {
            return null;
        }
        foreach ($this->types as $type) {
            if (in_array($type, $types, true)) {
                return $type;
            } elseif ('*/*' == $type) {
                return current($types);
            } elseif (strlen($type) > 2 && substr($type, -2, 2) == '/*') {
                $prefix = substr($type, 0, strpos($type, '/') + 1);
                $plen = strlen($prefix);
                foreach ($types as $t) {
                    if (strncmp($prefix, $t, $plen) === 0) {
                        return $t;
                    }
                }
            }
        }
        return null;
    }
public function preferred(array $types): ?string
    {
        if (empty($types)) {
            return null;
        }
        foreach ($this->types as $type) {
            if (in_array($type, $types, true)) {
                return $type;
            } elseif ('*/*' == $type) {
                return current($types);
            } elseif (strlen($type) > 2 && substr($type, -2, 2) == '/*') {
                $prefix = substr($type, 0, strpos($type, '/') + 1);
                $plen = strlen($prefix);
                foreach ($types as $t) {
                    if (strncmp($prefix, $t, $plen) === 0) {
                        return $t;
                    }
                }
            }
        }
        return null;
    }
Returns the most preferred MIME type out of the provided list.

This method will iterate through the stored MIME types in preferred order
and attempt to match them to those provided.

Say for example the HTTP Accept header was:
`text/html,application/xhtml+xml,application/xml;q=0.9,text/*;q=0.8`.

```php
// will return 'text/html'
$types->preferred(['text/css', 'text/html', 'application/javascript']);
// will return 'application/xml'
$types->preferred(['application/xml', 'text/css', 'application/json']);
// will return 'text/plain'
$types->preferred(['text/plain', 'text/css', 'application/json']);
// will return null
$types->preferred(['application/json', 'application/octet-stream']);
// will return null
$types->preferred([]);
```

@param string[] $types The MIME types to compare
@return string|null The most preferred MIME type or null