Skip to content

Commit

Permalink
Fix type error into String helper when argument is not a string
Browse files Browse the repository at this point in the history
  • Loading branch information
webeweb committed Jun 12, 2024
1 parent 4511062 commit 3b20e13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/Helper/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ public static function parseArray(array $values): string {

if (true === is_array($value)) {
$buffer = trim(implode(" ", $value));
} elseif (true === is_bool($value)) {
$buffer = static::parseBoolean($value);
} elseif (true === is_numeric($value)) {
$buffer = $value;
} else {
$buffer = trim($value);
}
Expand Down
12 changes: 8 additions & 4 deletions tests/Helper/StringHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,20 @@ public function testMoreThan(): void {
public function testParseArray(): void {

$arg = [
"exception" => null,
"id" => "id",
"class" => [
"exception" => null,
"id" => "id",
"class" => [
"class1",
"class2",
"class3 class4",
],
"data-type-boolean" => true,
"data-type-float" => 0.1,
"data-type-integer" => 1,
];
$exp = 'id="id" class="class1 class2 class3 class4" data-type-boolean="true" data-type-float="0.1" data-type-integer="1"';

$this->assertEquals('id="id" class="class1 class2 class3 class4"', StringHelper::parseArray($arg));
$this->assertEquals($exp, StringHelper::parseArray($arg));
}

/**
Expand Down

0 comments on commit 3b20e13

Please sign in to comment.