Skip to content

Commit

Permalink
Merge pull request #18 from ayaseensd/main
Browse files Browse the repository at this point in the history
Reformat Arabic object & add isArabic method
  • Loading branch information
atmonshi authored Sep 27, 2022
2 parents 27ab0c9 + 7304e95 commit 171abcc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 29 deletions.
57 changes: 28 additions & 29 deletions src/ArPhpLaravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,103 +4,102 @@

class ArPhpLaravel
{
public static function int2str($integer, $numberFeminine = 1, $numberFormat = 1, $setNumberOrder = null)
private static function Arabic()
{
return new \ArPHP\I18N\Arabic();
}

public static function isArabic($text)
{
$Arabic = new \ArPHP\I18N\Arabic();
return self::Arabic()->isArabic($text);
}

$Arabic->setNumberFeminine($numberFeminine);
$Arabic->setNumberFormat($numberFormat);
public static function int2str($integer, $numberFeminine = 1, $numberFormat = 1, $setNumberOrder = null)
{
self::Arabic()->setNumberFeminine($numberFeminine);
self::Arabic()->setNumberFormat($numberFormat);
if ($setNumberOrder !== null) {
$Arabic->setNumberOrder($setNumberOrder);
self::Arabic()->setNumberOrder($setNumberOrder);
}

return $Arabic->int2str($integer);
return self::Arabic()->int2str($integer);
}

public static function str2int($number)
{
$Arabic = new \ArPHP\I18N\Arabic();

return $Arabic->str2int($number);
return self::Arabic()->str2int($number);
}

public static function arSentiment($text)
{
$Arabic = new \ArPHP\I18N\Arabic();

return ($Arabic->arSentiment($text) > 0)
return (self::Arabic()->arSentiment($text) > 0)
? __('arPhpLaravel::arPhpLaravel.positive')
: __('arPhpLaravel::arPhpLaravel.negative');
}

public static function en2ar($text)
{
return ( new \ArPHP\I18N\Arabic() )->en2ar($text);
return self::Arabic()->en2ar($text);
}

public static function ar2en($text)
{
return ( new \ArPHP\I18N\Arabic() )->ar2en($text);
return self::Arabic()->ar2en($text);
}

public static function isFemale($text)
{
return ( new \ArPHP\I18N\Arabic() )->isFemale($text);
return self::Arabic()->isFemale($text);
}

public static function guessGender($text)
{
$Arabic = new \ArPHP\I18N\Arabic();

return ($Arabic->isFemale($text) === true)
return (self::Arabic()->isFemale($text) === true)
? __('arPhpLaravel::arPhpLaravel.female')
: __('arPhpLaravel::arPhpLaravel.male');
}

public static function strtotime($text, $time, $format = 'l dS F Y')
{
$Arabic = new \ArPHP\I18N\Arabic();

$int = $Arabic->strtotime($text, $time);
$int = self::Arabic()->strtotime($text, $time);

return date($format, $int);
}

public static function standard($text)
{
return ( new \ArPHP\I18N\Arabic() )->standard($text);
return self::Arabic()->standard($text);
}

public static function arSummary($text, $keywords, $int, $mode, $output, $style = null)
{
return ( new \ArPHP\I18N\Arabic() )->arSummary($text, $keywords, $int, $mode, $output, $style);
return self::Arabic()->arSummary($text, $keywords, $int, $mode, $output, $style);
}

public static function money2str($number, $iso = 'SAR', $lang = 'ar')
{
return ( new \ArPHP\I18N\Arabic() )->money2str($number, $iso, $lang);
return self::Arabic()->money2str($number, $iso, $lang);
}

public static function int2indic($number)
{
return ( new \ArPHP\I18N\Arabic() )->int2indic($number);
return self::Arabic()->int2indic($number);
}

public static function utf8Glyphs($text)
{
return ( new \ArPHP\I18N\Arabic() )->utf8Glyphs($text);
return self::Arabic()->utf8Glyphs($text);
}

public static function plural($singular, $count, $plural2 = null, $plural3 = null, $plural4 = null)
{
$Arabic = new \ArPHP\I18N\Arabic();
$text = $Arabic->arPlural($singular, $count, $plural2, $plural3, $plural4);
$text = self::Arabic()->arPlural($singular, $count, $plural2, $plural3, $plural4);

return str_replace('%d', $count, $text);
}

public static function translate($text)
{
return ( new \ArPHP\I18N\Arabic() )->ar2en($text);
return self::Arabic()->ar2en($text);
}
}
14 changes: 14 additions & 0 deletions tests/arPhpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ protected function overrideApplicationProviders()
];
}

/** @test */
public function it_is_not_arabic_text()
{
$output = ArPhpLaravel::isArabic("Hello there");

$this->assertSame(false, $output);
}
/** @test */
public function it_is_arabic_text()
{
$output = ArPhpLaravel::isArabic("مرحبا");

$this->assertSame(true, $output);
}
/** @test */
public function int2str_convert_number_to_text()
{
Expand Down

0 comments on commit 171abcc

Please sign in to comment.