Skip to content

Commit f44967f

Browse files
author
Alex Westergaard
committed
Add conversion to item inside FromArray if not Item
1 parent 8a3a7e2 commit f44967f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Helper/IOHelper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace AlexWestergaard\PhpGa4\Helper;
44

5+
use AlexWestergaard\PhpGa4\Item;
6+
use AlexWestergaard\PhpGa4\Facade\Type\ItemType;
57
use AlexWestergaard\PhpGa4\Facade\Type\IOType;
68
use AlexWestergaard\PhpGa4\Exception\Ga4IOException;
79

@@ -303,6 +305,10 @@ public static function fromArray(IOType|array $importable): static
303305
foreach ($importable as $key => $val) {
304306
if (is_array($val)) {
305307
foreach ($val as $single) {
308+
if (in_array($key, ['item', 'items']) && !($importable instanceof ItemType)) {
309+
$single = Item::fromArray($single);
310+
}
311+
306312
$static[$key] = $single;
307313
}
308314
} else {

0 commit comments

Comments
 (0)