src/ScContent/Service/FileTypesCatalog.php
public function isAllowed($spec, $pattern)
    {
        if (! array_key_exists($spec, $this->catalogue)) {
            return false;
        }
        $features = $this->catalogue[$spec];
        if (! is_array($pattern)) {
            $pattern = [$pattern];
        }
        $needle = 0;
        foreach ($pattern as $term) {
            $needle |= $term;
        }
        return $needle === ($features & $needle);
    }
public function isAllowed($spec, $pattern)
    {
        if (! array_key_exists($spec, $this->catalogue)) {
            return false;
        }
        $features = $this->catalogue[$spec];
        if (! is_array($pattern)) {
            $pattern = [$pattern];
        }
        $needle = 0;
        foreach ($pattern as $term) {
            $needle |= $term;
        }
        return $needle === ($features & $needle);
    }
public function isAllowed ( $ spec , $ pattern ) { if ( ! array_key_exists ( $ spec , $ this -> catalogue ) ) { return false ; } $ features = $ this -> catalogue [ $ spec ] ; if ( ! is_array ( $ pattern ) ) { $ pattern = [ $ pattern ] ; } $ needle = 0 ; foreach ( $ pattern as $ term ) { $ needle |= $ term ; } return $ needle === ( $ features & $ needle ) ; }
Returns true if and only if the file specification
is allowed for a given pattern.

Usage:
<code>
// for example, you have file extension and mime
$extension = 'jpeg';
$mime = 'image/jpeg';

$spec = $extension . ':' . $mime;

// you want to allow only editable images
$pattern = Catalog::Image | Catalog::GdEditable;

$isAllowed = $catalog->isAllowed($spec, $pattern);
</code>

How to allow editable images AND music?
<code>
// for example, you have file extension and mime
$extension = 'jpeg';
$mime = 'image/jpeg';

$spec = $extension . ':' . $mime;

$patterns = array(
Catalog::Image | Catalog::GdEditable,
Catalog::Audio,
);
$isAllowed = false;
foreach ($patterns as $pattern) {
if ($catalog->isAllowed($spec, $pattern)) {
$isAllowed = true;
}
}
if ($isAllowed) {
// your code here
}
</code>

The recommended pattern is Catalog::Safe

@api

@param  string $spec
$param  integer|array $pattern
@return boolean
Returns true if and only if the file specification is allowed for a given pattern .