for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace NBN\LoadBalancer\Host;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* @author Nicolas Bastien <[email protected]>
*/
class Host implements HostInterface
{
* @var string
protected $id;
protected $url;
* @var array
protected $settings;
* @param string $id
* @param string $url
* @param array $settings
public function __construct($id, $url, array $settings)
$this->id = $id;
$this->url = $url;
$this->settings = $settings;
}
* {@inheritdoc}
public function getId()
return $this->id;
public function getUrl()
return $this->url;
public function getSettings()
return $this->settings;
* @param string $name Setting name
* @param mixed $default Default value is setting is not set
* @return mixed
public function getSetting($name, $default = null)
if (isset($this->settings[$name])) {
return $this->settings[$name];
return $default;
public function getLoad()
//if load is not defined presume it's overloaded
return $this->getSetting('load', 1);
public function handleRequest(Request $request)
$response = new Response();
$response->setStatusCode($this->getSetting('response-status', 200));
$response->setContent(sprintf($this->getSetting('response-content-format', '%s'), $request->getUri()));
return $response;