Skip to content

Commit

Permalink
[5.x] Extract text direction for reuse (#9730)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Varga <[email protected]>
  • Loading branch information
jesseleite and jasonvarga authored Mar 14, 2024
1 parent cb7eaaa commit 5d8c96c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Statamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Statamic\Support\Arr;
use Statamic\Support\DateFormat;
use Statamic\Support\Str;
use Statamic\Support\TextDirection;
use Statamic\Tags\FluentTag;
use Stringy\StaticStringy;

Expand Down Expand Up @@ -479,8 +480,6 @@ public static function cpLocale(): string

public static function cpDirection()
{
$rtl = ['ar', 'fa', 'he', 'ps', 'ur'];

return in_array(static::cpLocale(), $rtl) ? 'rtl' : 'ltr';
return TextDirection::of(static::cpLocale());
}
}
13 changes: 13 additions & 0 deletions src/Support/TextDirection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Statamic\Support;

class TextDirection
{
private const RTL = ['ar', 'fa', 'he', 'ps', 'ur'];

public static function of(string $lang): string
{
return in_array($lang, static::RTL) ? 'rtl' : 'ltr';
}
}

0 comments on commit 5d8c96c

Please sign in to comment.