feat: fallback to dev server if none provided

This commit is contained in:
Jamie Barton 2024-07-16 12:27:47 +01:00
parent b44f3ebc90
commit 219ae52bf3

View File

@ -2,6 +2,8 @@
namespace Dumbo;
use Dumbo\Adapters\PhpDevelopmentServer;
class Dumbo
{
private $routes = [];
@ -9,9 +11,9 @@ class Dumbo
private $prefix = "";
private $server;
public function __construct(ServerInterface $server)
public function __construct(ServerInterface $server = null)
{
$this->server = $server;
$this->server = $server ?? $this->createDefaultServer();
}
public function __call($method, $arguments)
@ -181,4 +183,9 @@ class Dumbo
return $next($context);
}
private function createDefaultServer(): ServerInterface
{
return new PhpDevelopmentServer();
}
}