for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace FlatPlan\Components;
class Structure extends AbstractComponent {
private $role;
private $components;
protected $roles = ['aside', 'chapter', 'container', 'divider', 'header'];
/**
* @param string $role
* @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 setComponents($components)
if (is_array($components)) {
foreach ($components as $component) {
if ($component instanceof AbstractComponent) {
array_push($this->components, $component);
} else if ($components instanceof AbstractComponent) {
array_push($this->components, $components);
public function getComponents()
return $this->components;
public function getComponent()
$component = new \stdClass();
$component->role = $this->getRole();
$component->components = $this->getComponents();
return $component;
public function __toString()
return json_encode($this->getComponent());