Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 8
Http
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 8
 __construct
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 4
 run
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 4
<?php
namespace Eywa\Http\Server {
    use Eywa\Console\Shell;
    use Symfony\Component\Console\Style\SymfonyStyle;
    class Http
    {
        /**
         *
         * The console output
         *
         */
        private SymfonyStyle $io;
        /**
         *
         * The command instance
         *
          */
        private Shell $http;
        /**
         *
         * The server url
         *
         */
        private string $url;
        /**
         *
         * Http constructor.
         *
         * @param SymfonyStyle $io
         * @param string $directory
         * @param int $port
         */
        public function __construct(SymfonyStyle $io, string $directory = 'web', int $port = 3000)
        {
            $this->url = "http://localhost:$port";
            $this->http = new Shell(sprintf('php -S 0.0.0.0:%d -t %s', $port, $directory));
            $this->io = $io;
        }
        /**
         * @return int
         */
        public function run(): int
        {
            $this->io->title('Starting the development server');
            $this->io->success(sprintf('The server is running and listen at %s', $this->url));
            $this->http->get()->setTimeout(null)->run();
            return 0;
        }
    }
}