Added trait function to check if the content type is supported.

This commit is contained in:
abdulmohsen
2024-06-09 16:31:06 +03:00
parent 52572c6dfc
commit bcacbd2852
2 changed files with 25 additions and 2 deletions

View File

@@ -81,9 +81,8 @@ trait JellyfinActionTrait
str_pad((string)ag($item, 'IndexNumber', 0), 3, '0', STR_PAD_LEFT),
),
default => throw new InvalidArgumentException(
r("Unexpected Content type '{type}' was received. '{content}'.", [
r("Unexpected Content type '{type}' was received.", [
'type' => $type,
'content' => arrayToString($item),
])
),
},
@@ -320,4 +319,16 @@ trait JellyfinActionTrait
return $response->response;
}
/**
* Check if the content type is supported WatchState.
*
* @param string $type The type to check.
*
* @return bool Returns true if the type is supported.
*/
protected function isSupportedType(string $type): bool
{
return in_array(JellyfinClient::TYPE_MAPPER[$type] ?? $type, iState::TYPES_LIST, true);
}
}

View File

@@ -350,4 +350,16 @@ trait PlexActionTrait
return $response->response;
}
/**
* Check if the content type is supported WatchState.
*
* @param string $type The type to check.
*
* @return bool Returns true if the type is supported.
*/
protected function isSupportedType(string $type): bool
{
return in_array(PlexClient::TYPE_MAPPER[$type] ?? $type, iState::TYPES_LIST, true);
}
}