Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ function endpush(): void
Stacks::end();
}

function push(string $name, bool $once = false): void
function push(string|array $name, bool $once = false): void
{
Stacks::open($name, $once);
is_array($name) ? Stacks::set($name) : Stacks::open($name, $once);

}

function stack(string $name, bool $return = false): string|null
Expand Down
11 changes: 11 additions & 0 deletions src/Stacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ public static function get($name): array
return self::$stacks[$name] ?? [];
}

public static function set(string|array $key, $value = null): array
{
if (is_array($key) === true) {
return static::$stacks = array_merge(static::$stacks, $key);
}

static::$stacks[$key] = $value;
return static::$stacks;
}


public static function end(): void
{
$current = self::$current;
Expand Down