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 = []; $this->pushStack = [];
} }
/**
* Flush stack by key.
*
* @return void
*/
public function flushStack($key = null) public function flushStack($key = null)
{ {
if (array_key_exists($key, $this->pushes)) { $properties = [
unset($this->pushes[$key]); 'pushes',
'prepends',
'pushStack',
];
foreach ($properties as $property) {
if (!array_key_exists($key, $this->$property)) {
continue;
} }
if (array_key_exists($key, $this->prepends)) { unset($this->$property[$key]);
unset($this->prepends[$key]);
}
if (array_key_exists($key, $this->pushStack)) {
unset($this->pushStack[$key]);
} }
} }
} }