protected function createFilter($key, $value)
    {
        if ($key == 'role') {
            return function (Attachment $attachment) use ($value) {
                return $attachment->getRole() == $value;
            };
        }

        if ($key == 'mimetype' || $key == 'type') {
            return function (Attachment $attachment) use ($value) {
                return $attachment->is($value);
            };
        }

        throw new UnsupportedParameterException("Filtering by key '$key' is not supported.'");
    }