EntryCollection   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 53
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sorted() 0 17 3
A labels() 0 17 2
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
0 ignored issues
show
Bug introduced by
There is no parameter named $reverse. Was it maybe removed?

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 method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
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