Slide::displayIndex()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 10
rs 9.4286
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace WITR\Slideshow;
4
5
class Slide
6
{
7
    protected $show;
8
    protected $type;
9
    protected $playOrder;
10
    protected $index;
11
12
    public static function fromScheduledShow($show)
13
    {
14
        $slide = new Slide();
15
16
        $slide->type = 'SHOW';
17
        $slide->show = $show;
18
19
        return $slide;
20
    }
21
22
    public static function fromEvent($event)
23
    {
24
        $slide = new Slide();
25
26
        $slide->type = 'EVENT';
27
        $slide->event = $event;
0 ignored issues
show
Bug introduced by
The property event does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
28
29
        return $slide;
30
    }
31
32
    public function playOrder($playOrder)
33
    {
34
        $this->playOrder = $playOrder;
35
    }
36
37
    public function displayText()
38
    {
39
        if ($this->type == 'EVENT')
40
        {
41
            return;
42
        }
43
44
        if ($this->playOrder == 0)
45
        {
46
            return '&#9658;&nbsp;Now Playing';
47
        }
48
49
        if ($this->playOrder == 1)
50
        {
51
            return 'Up Next:';
52
        }
53
54
        return $this->show->getRelativeAirDate() . ' ' . $this->show->timespan();
55
    }
56
57
    public function image()
58
    {
59
        if ($this->type == 'EVENT')
60
        {
61
            return $this->event->picture;
62
        }
63
64
        return $this->show->sliderPicture();
65
    }
66
67
    public function textStyle()
68
    {
69
        if ($this->type != 'SHOW')
70
        {
71
            return;
72
        }
73
        
74
        return $this->show->sliderStyle();
75
    }
76
77
    public function url()
78
    {
79
        if ($this->type != 'EVENT')
80
        {
81
            return;
82
        }
83
84
        return $this->event->url;
85
    }
86
87
    public function type()
88
    {
89
        return $this->type;
90
    }
91
92
    public function index($index)
93
    {
94
        $this->index = $index;
95
    }
96
97
    public function displayIndex()
98
    {
99
        $display = [
100
            0 => 'first',
101
            1 => 'second',
102
            2 => 'third',
103
            3 => 'fourth',
104
        ];
105
        return $display[$this->index];
106
    }
107
}
108