for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace FlatPlan\Components;
class Text extends AbstractComponent {
protected $text;
protected $format;
protected $textStyle;
protected $formats = ['html', 'markdown', 'none'];
protected $roles = ['body', 'title', 'heading', 'intro', 'caption', 'author', 'byline', 'illustrator', 'photographer', 'quote', 'pullquote'];
/**
* @param string $role
* @param string $text
* @param string $format
* @return void
*/
public function __construct($role, $text, $format = 'none')
{
$this->setRole($role);
$this->setText($text);
$this->setFormat($format);
}
private function setText($text)
$this->text = $text;
private function getText()
return $this->text;
private function setFormat($format = null)
if (!in_array($format, $this->formats)) {
throw new \ErrorException('Invalid format supplied.');
$this->format = $format;
private function getFormat()
return $this->format;
protected function getComponent()
$component = new \stdClass();
$component->text = $this->getText();
$component->role = $this->getRole();
$component->format = $this->getFormat();
return $component;