for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace FlatPlan\Components;
class Social extends AbstractComponent {
private $role;
private $url;
protected $roles = ['instagram', 'facebook_post', 'tweet'];
/**
* @param string $role
* @param string $url
* @return void
*/
public function __construct($role, $url)
{
$this->setRole($role);
$this->setUrl($url);
}
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 setUrl($url)
if (!filter_var($url, FILTER_VALIDATE_URL)) {
throw new \ErrorException('Invalid url supplied.');
$this->url = $url;
public function getUrl()
return $this->url;
public function getComponent()
$component = new \stdClass();
$component->role = $this->getRole();
$component->url = $this->getUrl();
return $component;
public function __toString()
return json_encode($this->getComponent());