Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1431795
SplDoublyLinkedListFilter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
SplDoublyLinkedListFilter.php
View Options
<?php
namespace
DeepCopy\TypeFilter\Spl
;
use
Closure
;
use
DeepCopy\DeepCopy
;
use
DeepCopy\TypeFilter\TypeFilter
;
use
SplDoublyLinkedList
;
/**
* @final
*/
class
SplDoublyLinkedListFilter
implements
TypeFilter
{
private
$copier
;
public
function
__construct
(
DeepCopy
$copier
)
{
$this
->
copier
=
$copier
;
}
/**
* {@inheritdoc}
*/
public
function
apply
(
$element
)
{
$newElement
=
clone
$element
;
$copy
=
$this
->
createCopyClosure
();
return
$copy
(
$newElement
);
}
private
function
createCopyClosure
()
{
$copier
=
$this
->
copier
;
$copy
=
function
(
SplDoublyLinkedList
$list
)
use
(
$copier
)
{
// Replace each element in the list with a deep copy of itself
for
(
$i
=
1
;
$i
<=
$list
->
count
();
$i
++)
{
$copy
=
$copier
->
recursiveCopy
(
$list
->
shift
());
$list
->
push
(
$copy
);
}
return
$list
;
};
return
Closure
::
bind
(
$copy
,
null
,
DeepCopy
::
class
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 21:04 (1 d, 14 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
fa/1b/c3abbebe2233ad85fb548e11cb2d
Default Alt Text
SplDoublyLinkedListFilter.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment