Skip to content

Commit

Permalink
if $text is NULL or Empty, return original text
Browse files Browse the repository at this point in the history
  • Loading branch information
Tint Naing Win committed Oct 1, 2019
1 parent 441ec70 commit 2dd30f8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/MyanFont.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MyanFont
public static function zg2uni($text = '')
{
if (self::isEmptyString($text)) {
return '';
return $text;
}

$font = self::ZgOrUni($text);
Expand All @@ -44,7 +44,7 @@ public static function zg2uni($text = '')
public static function uni2zg($text)
{
if (self::isEmptyString($text)) {
return '';
return $text;
}

$font = self::ZgOrUni($text);
Expand Down
19 changes: 16 additions & 3 deletions tests/MyanFontTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,26 @@ public function convert_uni2zg()
public function null_convert()
{
$zg = MyanFont::uni2zg(null);
$this->assertNotNull($zg);
$this->assertNull($zg);

$uni = MyanFont::zg2uni(null);
$this->assertNotNull($uni);
$this->assertNull($uni);

$font = MyanFont::isZgOrUni(null);
$this->assertNotNull($font);
$this->assertEquals($font, self::UNICODE);
}

/** @test */
public function empty_string_convert()
{
$zg = MyanFont::uni2zg('');
$this->assertEmpty($zg);

$uni = MyanFont::zg2uni('');
$this->assertEmpty($uni);

$font = MyanFont::isZgOrUni('');
$this->assertEquals($font, self::UNICODE);
}

/** @test */
Expand Down

0 comments on commit 2dd30f8

Please sign in to comment.