for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace FlatPlan\Components;
use FlatPlan\Components\Image;
class Gallery extends AbstractComponent {
private $role;
private $items = array();
protected $roles = ['gallery', 'mosaic'];
/**
* @param string $role
* @param string $bannerType
* @return void
*/
public function __construct($role)
{
$this->setRole($role);
}
public function setRole($role)
if (!in_array($role, $this->roles)) {
throw new \ErrorException('Invalid role supplied.');
$this->role = $role;
public function getRole()
return $this->role;
public function setItem($item)
if ($item instanceof Image) {
array_push($this->items, $item);
} else {
throw new \ErrorException('Invalid image component supplied.');
public function getItems()
return $this->items;
public function getComponent()
$component = new \stdClass();
$component->role = $this->getRole();
$component->items = $this->getItems();
return $component;
public function __toString()
return json_encode($this->getComponent());