1
|
|
|
<?php namespace Anomaly\Streams\Platform\Entry; |
2
|
|
|
|
3
|
|
|
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface; |
4
|
|
|
use Anomaly\Streams\Platform\Model\EloquentCollection; |
5
|
|
|
use Anomaly\Streams\Platform\Support\Decorator; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class EntryCollection |
9
|
|
|
* |
10
|
|
|
* @link http://pyrocms.com/ |
11
|
|
|
* @author PyroCMS, Inc. <[email protected]> |
12
|
|
|
* @author Ryan Thompson <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
class EntryCollection extends EloquentCollection |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Return the sorted entries. |
19
|
|
|
* |
20
|
|
|
* @param bool|false $reverse |
|
|
|
|
21
|
|
|
* @return static |
22
|
|
|
*/ |
23
|
|
|
public function sorted($direction = 'asc') |
24
|
|
|
{ |
25
|
|
|
$items = []; |
26
|
|
|
|
27
|
|
|
/* @var EntryInterface $item */ |
28
|
|
|
foreach ($this->items as $item) { |
29
|
|
|
$items[$item->getSortOrder()] = $item; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
ksort($items); |
33
|
|
|
|
34
|
|
|
if (strtolower($direction) == 'desc') { |
35
|
|
|
$items = array_reverse($items); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
return self::make($items); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Return labels for each entry. |
43
|
|
|
* |
44
|
|
|
* @param null $text |
45
|
|
|
* @param string $context |
46
|
|
|
* @param string $size |
47
|
|
|
* @return array |
48
|
|
|
*/ |
49
|
|
|
public function labels($text = null, $context = null, $size = null) |
50
|
|
|
{ |
51
|
|
|
$decorator = new Decorator(); |
52
|
|
|
|
53
|
|
|
return array_map( |
54
|
|
|
function ($entry) use ($decorator, $text, $context, $size) { |
55
|
|
|
|
56
|
|
|
/* @var EntryPresenter $entry */ |
57
|
|
|
if (!$entry instanceof EntryPresenter) { |
58
|
|
|
$entry = $decorator->decorate($entry); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return $entry->label($text, $context, $size); |
62
|
|
|
}, |
63
|
|
|
$this->all() |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.