StreamPresenter::translatableLabel()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

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