Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
W
wp-persistence
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
Library
wp-persistence
Commits
e963c98f
Unverified
Commit
e963c98f
authored
3 years ago
by
Bartek Jaskulski
Browse files
Options
Downloads
Patches
Plain Diff
fix: use `set` in `get` method consistently
parent
9314a136
No related branches found
No related tags found
1 merge request
!9
fix: use `set` in `get` method consistently
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+5
-1
5 additions, 1 deletion
CHANGELOG.md
src/Adapter/ArrayContainer.php
+42
-42
42 additions, 42 deletions
src/Adapter/ArrayContainer.php
with
47 additions
and
43 deletions
CHANGELOG.md
+
5
−
1
View file @
e963c98f
## [3.0.2] - Unreleased
### Fixed
-
`ArrayContainer::get`
now uses
`ArrayContainer::set`
for value presence check
## [3.0.1] - 2021-08-14
### Added
-
Added set_expiration method for WordPressTransientContainer class
...
...
@@ -59,4 +63,4 @@
## [1.0.0] - 2019-02-04
### Added
-
first stable version
\ No newline at end of file
-
first stable version
This diff is collapsed.
Click to expand it.
src/Adapter/ArrayContainer.php
+
42
−
42
View file @
e963c98f
...
...
@@ -12,45 +12,45 @@ use WPDesk\Persistence\PersistentContainer;
* @package WPDesk\Persistence
*/
class
ArrayContainer
implements
PersistentContainer
{
use
FallbackFromGetTrait
;
/** @var array */
protected
$array
;
public
function
__construct
(
array
$initial
=
[]
)
{
$this
->
array
=
$initial
;
}
public
function
set
(
string
$id
,
$value
)
{
if
(
$value
===
null
)
{
$this
->
delete
(
$id
);
}
else
{
$this
->
array
[
$id
]
=
$value
;
}
}
public
function
delete
(
string
$id
)
{
unset
(
$this
->
array
[
$id
]
);
}
public
function
has
(
$id
):
bool
{
return
key_exists
(
$id
,
$this
->
array
);
}
public
function
get
(
$id
)
{
if
(
!
isset
(
$this
->
array
[
$id
]
)
)
{
throw
new
ElementNotExistsException
(
sprintf
(
'Element %s not exists!'
,
$id
)
);
}
return
$this
->
array
[
$id
];
}
/**
* Return array that is used internally to save the data.
*
* @return array
*/
public
function
get_array
()
{
return
$this
->
array
;
}
}
\ No newline at end of file
use
FallbackFromGetTrait
;
/** @var array */
protected
$array
;
public
function
__construct
(
array
$initial
=
[]
)
{
$this
->
array
=
$initial
;
}
public
function
set
(
string
$id
,
$value
)
{
if
(
$value
===
null
)
{
$this
->
delete
(
$id
);
}
else
{
$this
->
array
[
$id
]
=
$value
;
}
}
public
function
delete
(
string
$id
)
{
unset
(
$this
->
array
[
$id
]);
}
public
function
has
(
$id
):
bool
{
return
key_exists
(
$id
,
$this
->
array
);
}
public
function
get
(
$id
)
{
if
(
!
$this
->
has
(
$id
)
)
{
throw
new
ElementNotExistsException
(
sprintf
(
'Element %s not exists!'
,
$id
));
}
return
$this
->
array
[
$id
];
}
/**
* Return array that is used internally to save the data.
*
* @return array
*/
public
function
get_array
()
{
return
$this
->
array
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment