Skip to content

Commit 641c32b

Browse files
author
Andrey Helldar
committed
Added array and object castable
1 parent 31c18f1 commit 641c32b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Concerns/HasCastable.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
namespace Helldar\PrettyArray\Concerns;
44

55
use function addslashes;
6+
use function is_array;
67
use function is_bool;
7-
use function is_numeric;
88
use function is_null;
9+
use function is_numeric;
10+
use function is_object;
911

1012
trait HasCastable
1113
{
@@ -30,6 +32,10 @@ protected function castValue($value = null)
3032
return 'null';
3133
}
3234

35+
if (is_array($value) || is_object($value)) {
36+
return '[]';
37+
}
38+
3339
return "'" . addslashes($value) . "'";
3440
}
3541
}

src/Services/Formatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected function pad(string $value, int $pad = 1, $type = STR_PAD_LEFT): strin
6565

6666
protected function value($value, int $pad = 1)
6767
{
68-
if (is_array($value)) {
68+
if (! empty($value) && (is_array($value) || is_object($value))) {
6969
return $this->raw($value, $pad);
7070
}
7171

0 commit comments

Comments
 (0)