It is generally recommended to explicitly declare the visibility for methods.
Adding explicit visibility (private, protected, or public) is generally
recommend to communicate to other developers how, and from where this method
is intended to be used.
Loading history...
30
{
31
6
if (!$strategy) {
32
5
$strategy = new SimpleSortStrategy();
33
5
}
34
35
6
$this->setStrategy($strategy);
36
6
}
37
38
/**
39
* @param StrategyInterface $strategy
40
*
41
* @return $this
42
*/
43
6
public function setStrategy($strategy)
44
{
45
6
$this->strategy = $strategy;
46
47
6
return $this;
48
}
49
50
/**
51
* Set sort order
52
*
53
* @param int $order
54
*
55
* @return $this
56
*/
57
1
public function setSortOrder($order)
58
{
59
1
$this->strategy->setSortOrder($order);
60
61
1
return $this;
62
}
63
64
/**
65
* {@inheritdoc}
66
*/
67
3
public function sort(array $collection)
68
{
69
3
if (!$this->strategy) {
70
throw new \RuntimeException('Strategy was not defined');
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.