for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace WITR\Slideshow;
class Slide
{
protected $show;
protected $type;
protected $playOrder;
protected $index;
public static function fromScheduledShow($show)
$slide = new Slide();
$slide->type = 'SHOW';
$slide->show = $show;
return $slide;
}
public static function fromEvent($event)
$slide->type = 'EVENT';
$slide->event = $event;
event
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;
public function playOrder($playOrder)
$this->playOrder = $playOrder;
public function displayText()
if ($this->type == 'EVENT')
return;
if ($this->playOrder == 0)
return '► Now Playing';
if ($this->playOrder == 1)
return 'Up Next:';
return $this->show->getRelativeAirDate() . ' ' . $this->show->timespan();
public function image()
return $this->event->picture;
return $this->show->sliderPicture();
public function textStyle()
if ($this->type != 'SHOW')
return $this->show->sliderStyle();
public function url()
if ($this->type != 'EVENT')
return $this->event->url;
public function type()
return $this->type;
public function index($index)
$this->index = $index;
public function displayIndex()
$display = [
0 => 'first',
1 => 'second',
2 => 'third',
3 => 'fourth',
];
return $display[$this->index];
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: