Code Duplication    Length = 80-80 lines in 2 locations

src/Assignment/AssignmentPresenter.php 1 location

@@ 13-92 (lines=80) @@
10
 * @author PyroCMS, Inc. <[email protected]>
11
 * @author Ryan Thompson <[email protected]>
12
 */
13
class AssignmentPresenter extends EloquentPresenter
14
{
15
16
    /**
17
     * The decorated object.
18
     * This is for IDE support.
19
     *
20
     * @var AssignmentInterface
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->requiredLabel($size),
36
                $this->uniqueLabel($size),
37
                $this->translatableLabel($size),
38
            ]
39
        );
40
    }
41
42
    /**
43
     * Return the required label.
44
     *
45
     * @param  string      $size
46
     * @return null|string
47
     */
48
    protected function requiredLabel($size = 'sm')
49
    {
50
        if ($this->object->isRequired()) {
51
            return '<span class="tag tag-danger tag-' . $size . '">' . trans(
52
                'streams::assignment.required.name'
53
            ) . '</span>';
54
        }
55
56
        return null;
57
    }
58
59
    /**
60
     * Return the unique label.
61
     *
62
     * @param  string      $size
63
     * @return null|string
64
     */
65
    protected function uniqueLabel($size = 'sm')
66
    {
67
        if ($this->object->isUnique()) {
68
            return '<span class="tag tag-primary tag-' . $size . '">' . trans(
69
                'streams::assignment.unique.name'
70
            ) . '</span>';
71
        }
72
73
        return null;
74
    }
75
76
    /**
77
     * Return the translatable label.
78
     *
79
     * @param  string      $size
80
     * @return null|string
81
     */
82
    protected function translatableLabel($size = 'sm')
83
    {
84
        if ($this->object->isTranslatable()) {
85
            return '<span class="tag tag-info tag-' . $size . '">' . trans(
86
                'streams::assignment.translatable.name'
87
            ) . '</span>';
88
        }
89
90
        return null;
91
    }
92
}
93

src/Stream/StreamPresenter.php 1 location

@@ 13-92 (lines=80) @@
10
 * @author PyroCMS, Inc. <[email protected]>
11
 * @author Ryan Thompson <[email protected]>
12
 */
13
class StreamPresenter extends Presenter
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