flushStack function re-factor

This commit is contained in:
Cüneyt Şentürk 2020-09-18 17:18:48 +03:00
parent ac2576d991
commit 516d506f4e

View File

@ -177,18 +177,25 @@ trait ManagesStacks
$this->pushStack = [];
}
/**
* Flush stack by key.
*
* @return void
*/
public function flushStack($key = null)
{
if (array_key_exists($key, $this->pushes)) {
unset($this->pushes[$key]);
}
{
$properties = [
'pushes',
'prepends',
'pushStack',
];
if (array_key_exists($key, $this->prepends)) {
unset($this->prepends[$key]);
}
foreach ($properties as $property) {
if (!array_key_exists($key, $this->$property)) {
continue;
}
if (array_key_exists($key, $this->pushStack)) {
unset($this->pushStack[$key]);
unset($this->$property[$key]);
}
}
}