Skip to content

Commit

Permalink
Update code based on feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 31, 2018
1 parent a8c9364 commit 4fc958b
Showing 1 changed file with 14 additions and 28 deletions.
42 changes: 14 additions & 28 deletions src/Shell/ServerShell.php
Expand Up @@ -43,41 +43,28 @@ class ServerShell extends Shell
*
* @var string
*/
protected $_host;
protected $_host = self::DEFAULT_HOST;

/**
* listen port
*
* @var int
*/
protected $_port;
protected $_port = self::DEFAULT_PORT;

/**
* document root
*
* @var string
*/
protected $_documentRoot;
protected $_documentRoot = WWW_ROOT;

/**
* ini path
*
* @var string
*/
protected $_iniPath;

/**
* Override initialize of the Shell
*
* @return void
*/
public function initialize()
{
$this->_host = self::DEFAULT_HOST;
$this->_port = self::DEFAULT_PORT;
$this->_documentRoot = WWW_ROOT;
$this->_iniPath = '';
}
protected $_iniPath = '';

/**
* Starts up the Shell and displays the welcome message.
Expand All @@ -91,17 +78,17 @@ public function initialize()
*/
public function startup()
{
if (!empty($this->params['host'])) {
$this->_host = $this->params['host'];
if ($this->param('host')) {
$this->_host = $this->param('host');
}
if (!empty($this->params['port'])) {
$this->_port = $this->params['port'];
if ($this->param('port')) {
$this->_port = $this->param('port');
}
if (!empty($this->params['document_root'])) {
$this->_documentRoot = $this->params['document_root'];
if ($this->param('document_root')) {
$this->_documentRoot = $this->param('document_root');
}
if (!empty($this->params['ini_path'])) {
$this->_iniPath = $this->params['ini_path'];
if ($this->param('ini_path')) {
$this->_iniPath = $this->param('ini_path');
}

// For Windows
Expand All @@ -111,9 +98,8 @@ public function startup()
if (preg_match("/^([a-z]:)[\\\]+(.+)$/i", $this->_documentRoot, $m)) {
$this->_documentRoot = $m[1] . '\\' . $m[2];
}
if (substr($this->_iniPath, -1, 1) === DIRECTORY_SEPARATOR) {
$this->_iniPath = substr($this->_iniPath, 0, strlen($this->_iniPath) - 1);
}

$this->_iniPath = rtrim($this->_iniPath, DIRECTORY_SEPARATOR);
if (preg_match("/^([a-z]:)[\\\]+(.+)$/i", $this->_iniPath, $m)) {
$this->_iniPath = $m[1] . '\\' . $m[2];
}
Expand Down

0 comments on commit 4fc958b

Please sign in to comment.