Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
5da62fab
Commit
5da62fab
authored
May 09, 2013
by
Antonio Ramirez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#196 refactored method name
parent
673d2072
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
ArrayHelper.php
framework/helpers/base/ArrayHelper.php
+4
-4
ArrayHelperTest.php
tests/unit/framework/helpers/ArrayHelperTest.php
+2
-2
No files found.
framework/helpers/base/ArrayHelper.php
View file @
5da62fab
...
...
@@ -95,7 +95,7 @@ class ArrayHelper
* ~~~
* // $array = array('type'=>'A', 'options'=>array(1,2));
* // working with array
* $type = \yii\helpers\ArrayHelper::
popValu
e($array, 'type');
* $type = \yii\helpers\ArrayHelper::
remov
e($array, 'type');
* // $array content
* // $array = array('options'=>array(1,2));
* ~~~
...
...
@@ -105,10 +105,10 @@ class ArrayHelper
* @param mixed $default the default value to be returned if the specified key does not exist
* @return mixed|null the value of the element if found, default value otherwise
*/
public
static
function
popValu
e
(
&
$array
,
$key
,
$default
=
null
)
public
static
function
remov
e
(
&
$array
,
$key
,
$default
=
null
)
{
if
(
is_array
(
$array
))
{
$value
=
static
::
getValue
(
$array
,
$key
,
$default
)
;
if
(
is_array
(
$array
)
&&
(
isset
(
$array
[
$key
])
||
array_key_exists
(
$key
,
$array
))
)
{
$value
=
$array
[
$key
]
;
unset
(
$array
[
$key
]);
return
$value
;
}
...
...
tests/unit/framework/helpers/ArrayHelperTest.php
View file @
5da62fab
...
...
@@ -12,10 +12,10 @@ class ArrayHelperTest extends \yii\test\TestCase
}
public
function
test
Popvalu
e
()
public
function
test
Remov
e
()
{
$array
=
array
(
'name'
=>
'b'
,
'age'
=>
3
);
$name
=
ArrayHelper
::
popValu
e
(
$array
,
'name'
);
$name
=
ArrayHelper
::
remov
e
(
$array
,
'name'
);
$this
->
assertEquals
(
$name
,
'b'
);
$this
->
assertEquals
(
$array
,
array
(
'age'
=>
3
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment