Skip to content

Commit

Permalink
refactor: add guards
Browse files Browse the repository at this point in the history
  • Loading branch information
cschmatzler committed Sep 3, 2023
1 parent 10606b5 commit fbaf344
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/idiom/locales.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Idiom.Locales do
"""
@type get_hierarchy_opts() :: [fallback: String.t() | list(String.t())]
@spec get_hierarchy(String.t(), get_hierarchy_opts()) :: list(String.t())
def get_hierarchy(locale, opts \\ []) do
def get_hierarchy(locale, opts \\ []) when is_binary(locale) do
fallback = Keyword.get(opts, :fallback)

[
Expand Down Expand Up @@ -101,7 +101,7 @@ defmodule Idiom.Locales do
```
"""
@spec direction(String.t()) :: :ltr | :rtl
def direction(locale) do
def direction(locale) when is_binary(locale) do
language = get_language(locale)

if Enum.member?(@rtl_languages, language), do: :rtl, else: :ltr
Expand Down

0 comments on commit fbaf344

Please sign in to comment.