AssignmentPresenter::labels()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
1
<?php namespace Anomaly\Streams\Platform\Assignment;
2
3
use Anomaly\Streams\Platform\Assignment\Contract\AssignmentInterface;
4
use Anomaly\Streams\Platform\Model\EloquentPresenter;
5
6
/**
7
 * Class AssignmentPresenter
8
 *
9
 * @link   http://pyrocms.com/
10
 * @author PyroCMS, Inc. <[email protected]>
11
 * @author Ryan Thompson <[email protected]>
12
 */
13 View Code Duplication
class AssignmentPresenter extends EloquentPresenter
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 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