Completed
Push — master ( dca802...7eb0de )
by Ryan
07:03
created

StreamPresenter::trashableLabel()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 10
loc 10
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php namespace Anomaly\Streams\Platform\Stream;
2
3
use Anomaly\Streams\Platform\Stream\Contract\StreamInterface;
4
use Anomaly\Streams\Platform\Support\Presenter;
5
6
/**
7
 * Class StreamPresenter
8
 *
9
 * @link          http://pyrocms.com/
10
 * @author        PyroCMS, Inc. <[email protected]>
11
 * @author        Ryan Thompson <[email protected]>
12
 * @package       Anomaly\Streams\Platform\Stream
13
 */
14 View Code Duplication
class StreamPresenter extends Presenter
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16
17
    /**
18
     * The stream interface.
19
     *
20
     * @var StreamInterface
21
     */
22
    protected $object;
23
24
    /**
25
     * Return the flag labels.
26
     *
27
     * @param string $size
28
     * @return string
29
     */
30
    public function labels($size = 'sm')
31
    {
32
        return implode(
33
            ' ',
34
            [
35
                $this->translatableLabel($size),
36
                $this->trashableLabel($size),
37
                $this->sortableLabel($size)
38
            ]
39
        );
40
    }
41
42
    /**
43
     * Return the translatable label.
44
     *
45
     * @param string $size
46
     * @return null|string
47
     */
48
    protected function translatableLabel($size = 'sm')
49
    {
50
        if ($this->object->isTranslatable()) {
51
            return '<span class="label label-info label-' . $size . '">' . trans(
52
                'streams::field.translatable.name'
53
            ) . '</span>';
54
        }
55
56
        return null;
57
    }
58
59
    /**
60
     * Return the trashable label.
61
     *
62
     * @param string $size
63
     * @return null|string
64
     */
65
    protected function trashableLabel($size = 'sm')
66
    {
67
        if ($this->object->isTrashable()) {
68
            return '<span class="label label-danger label-' . $size . '">' . trans(
69
                'streams::field.trashable.name'
70
            ) . '</span>';
71
        }
72
73
        return null;
74
    }
75
76
    /**
77
     * Return the sortable label.
78
     *
79
     * @param string $size
80
     * @return null|string
81
     */
82
    protected function sortableLabel($size = 'sm')
83
    {
84
        if ($this->object->isSortable()) {
85
            return '<span class="label label-primary label-' . $size . '">' . trans(
86
                'streams::field.sortable.name'
87
            ) . '</span>';
88
        }
89
90
        return null;
91
    }
92
93
}
94