diff --git a/src/Config.php b/src/Config.php index 4e08b98..9e4cc74 100644 --- a/src/Config.php +++ b/src/Config.php @@ -73,6 +73,24 @@ class Config implements ConfigInterface } /** + * Return port number (get from defaults if port is not set by user) + * + * @param string $parameter + * @return bool|int + */ + private function getPort(string $parameter) + { + // If client need port number and port is not set + if ($parameter === 'port' && !isset($this->_parameters['port'])) { + // then use default with or without ssl encryption + return (isset($this->_parameters['ssl']) && $this->_parameters['ssl']) + ? Client::PORT_SSL + : Client::PORT; + } + return null; + } + + /** * Return parameter of current config by name * * @param string $parameter @@ -88,15 +106,7 @@ class Config implements ConfigInterface // __construct } - // If client need port number and port is not set - if ($parameter === 'port' && !isset($this->_parameters['port'])) { - // then use default with or without ssl encryption - return (isset($this->_parameters['ssl']) && $this->_parameters['ssl']) - ? Client::PORT_SSL - : Client::PORT; - } - - return $this->_parameters[$parameter]; + return $this->getPort($parameter) ?? $this->_parameters[$parameter]; } /**