-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0125ca2
commit 03a0cf3
Showing
3 changed files
with
15 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 1.1.1 | ||
* @version 1.1.2 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 InitPHP | ||
* @license http://initphp.github.io/license.txt MIT | ||
* @version 1.1.1 | ||
* @version 1.1.2 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|
@@ -32,6 +32,7 @@ | |
use function is_bool; | ||
use function array_map; | ||
use function array_change_key_case; | ||
use function array_key_exists; | ||
|
||
class ParameterBag implements ParameterBagInterface | ||
{ | ||
|
@@ -44,6 +45,9 @@ class ParameterBag implements ParameterBagInterface | |
'separator' => '.', | ||
]; | ||
|
||
/** @var array */ | ||
private $_PBCache = []; | ||
|
||
public function __construct(array $data = [], array $options = []) | ||
{ | ||
if(!empty($data)){ | ||
|
@@ -106,7 +110,7 @@ public function has(string $key): bool | |
if($this->_PBOptions['isMulti'] && strpos($key, $this->_PBOptions['separator']) !== FALSE){ | ||
return ($this->multiSubParameterGet($key) !== '__InitPHPP@r@m£t£rB@gN0tF0undV@lu€__'); | ||
} | ||
return isset($this->_PBStack[$key]); | ||
return isset($this->_PBStack[$key]) || array_key_exists($key, $this->_PBStack); | ||
} | ||
|
||
/** | ||
|
@@ -115,6 +119,9 @@ public function has(string $key): bool | |
public function get(string $key, $default = null) | ||
{ | ||
$key = $this->getKey($key); | ||
if(isset($this->_PBCache[$key])){ | ||
return $this->_PBCache[$key]; | ||
} | ||
if($this->_PBOptions['isMulti'] !== FALSE && strpos($key, $this->_PBOptions['separator']) !== FALSE){ | ||
$value = $this->multiSubParameterGet($key); | ||
return ($value !== '__InitPHPP@r@m£t£rB@gN0tF0undV@lu€__') ? $value : $default; | ||
|
@@ -131,6 +138,7 @@ public function set(string $key, $value): ParameterBagInterface | |
if(is_array($value)){ | ||
$value = $this->arrayChangeKeyCaseLower($value); | ||
} | ||
$this->_PBCache[$key] = $value; | ||
if($this->_PBOptions['isMulti'] !== FALSE && strpos($key, $this->_PBOptions['separator']) !== FALSE){ | ||
$split = explode($this->_PBOptions['separator'], $key); | ||
$id = $split[0]; | ||
|
@@ -149,6 +157,9 @@ public function remove(string ...$keys): ParameterBagInterface | |
{ | ||
foreach ($keys as $key) { | ||
$key = $this->getKey($key); | ||
if(array_key_exists($key, $this->_PBCache)){ | ||
unset($this->_PBCache[$key]); | ||
} | ||
if($this->_PBOptions['isMulti'] !== FALSE && strpos($key, $this->_PBOptions['separator']) !== FALSE){ | ||
$split = explode($this->_PBOptions['separator'], $key); | ||
$id = $keys[0]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @author Muhammet ŞAFAK <[email protected]> | ||
* @copyright Copyright © 2022 Muhammet ŞAFAK | ||
* @license ./LICENSE MIT | ||
* @version 1.1.1 | ||
* @version 1.1.2 | ||
* @link https://www.muhammetsafak.com.tr | ||
*/ | ||
|
||
|