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://anomaly.is/streams-platform |
11
|
|
|
* @author AnomalyLabs, Inc. <[email protected]> |
12
|
|
|
* @author Ryan Thompson <[email protected]> |
13
|
|
|
* @package Anomaly\Streams\Platform\Entry |
14
|
|
|
*/ |
15
|
|
|
class EntryCollection extends EloquentCollection |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Return the sorted entries. |
20
|
|
|
* |
21
|
|
|
* @param bool|false $reverse |
|
|
|
|
22
|
|
|
* @return static |
23
|
|
|
*/ |
24
|
|
|
public function sorted($direction = 'asc') |
25
|
|
|
{ |
26
|
|
|
$items = []; |
27
|
|
|
|
28
|
|
|
/* @var EntryInterface $item */ |
29
|
|
|
foreach ($this->items as $item) { |
30
|
|
|
$items[$item->getSortOrder()] = $item; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
ksort($items); |
34
|
|
|
|
35
|
|
|
if (strtolower($direction) == 'desc') { |
36
|
|
|
$items = array_reverse($items); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
return self::make($items); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Return labels for each entry. |
44
|
|
|
* |
45
|
|
|
* @param null $text |
46
|
|
|
* @param string $context |
47
|
|
|
* @param string $size |
48
|
|
|
* @return array |
49
|
|
|
*/ |
50
|
|
|
public function labels($text = null, $context = null, $size = null) |
51
|
|
|
{ |
52
|
|
|
$decorator = new Decorator(); |
53
|
|
|
|
54
|
|
|
return array_map( |
55
|
|
|
function ($entry) use ($decorator, $text, $context, $size) { |
56
|
|
|
|
57
|
|
|
/* @var EntryPresenter $entry */ |
58
|
|
|
if (!$entry instanceof EntryPresenter) { |
59
|
|
|
$entry = $decorator->decorate($entry); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return $entry->label($text, $context, $size); |
63
|
|
|
}, |
64
|
|
|
$this->all() |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
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.