FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
DesignPatternsPHP/Strategy/ObjectCollection.php at master · NandoKstroNet/DesignPatternsPHP · GitHub
NandoKstroNet
DesignPatternsPHP
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
DesignPatternsPHP
/
Strategy
/
ObjectCollection.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
48 lines (41 loc) · 811 Bytes
Breadcrumbs
DesignPatternsPHP
/
Strategy
/
ObjectCollection.php
Copy path
File metadata and controls
48 lines (41 loc) · 811 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace
DesignPatterns
\
Strategy
;
/**
* Class ObjectCollection
*/
class
ObjectCollection
{
/**
* @var array
*/
private
$
elements
;
/**
* @var ComparatorInterface
*/
private
$
comparator
;
/**
* @param array $elements
*/
public
function
__construct
(
array
$
elements
=
array
())
{
$
this
->
elements
=
$
elements
;
}
/**
* @return array
*/
public
function
sort
()
{
$
callback
=
array
(
$
this
->
comparator
,
'
compare
'
);
uasort
(
$
this
->
elements
,
$
callback
);
return
$
this
->
elements
;
}
/**
* @param ComparatorInterface $comparator
*
* @return void
*/
public
function
setComparator
(
ComparatorInterface
$
comparator
)
{
$
this
->
comparator
=
$
comparator
;
}
}
Back
|
FazBrowse Home
|
New Git URL