mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-12 02:11:45 +01:00
Configuration of connecting - do not allow to change (remove setters)
This commit is contained in:
@@ -80,12 +80,12 @@ class ConnectionConfiguration
|
||||
*/
|
||||
public function __construct($baseUrl, $username, $password, $debugMode = false, $verifySslCertificate = true)
|
||||
{
|
||||
$this
|
||||
->setBaseUrl($baseUrl)
|
||||
->setUsername($username)
|
||||
->setPassword($password)
|
||||
->setDebugMode($debugMode)
|
||||
->setVerifySslCertificate($verifySslCertificate);
|
||||
$this->setBaseUrl($baseUrl);
|
||||
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
$this->debugMode = $debugMode;
|
||||
$this->verifySslCertificate = $verifySslCertificate;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,29 +98,6 @@ class ConnectionConfiguration
|
||||
return $this->baseUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base url, protocol & domain
|
||||
*
|
||||
* @param string $baseUrl The base url, protocol & domain
|
||||
* @return $this
|
||||
*
|
||||
* @throws InvalidUrlException
|
||||
*/
|
||||
public function setBaseUrl($baseUrl)
|
||||
{
|
||||
if (!Regex::isValidUrl($baseUrl)) {
|
||||
throw new InvalidUrlException($baseUrl);
|
||||
}
|
||||
|
||||
if (Regex::endsWith($baseUrl, '/')) {
|
||||
$baseUrl = substr($baseUrl, 0, strlen($baseUrl) - 1);
|
||||
}
|
||||
|
||||
$this->baseUrl = $baseUrl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the url of the LimeSurvey's remote control
|
||||
*
|
||||
@@ -154,19 +131,6 @@ class ConnectionConfiguration
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of user used to authenticate to LimeSurvey
|
||||
*
|
||||
* @param string $username The name of user used to authenticate to LimeSurvey
|
||||
* @return $this
|
||||
*/
|
||||
public function setUsername($username)
|
||||
{
|
||||
$this->username = $username;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the password used to authenticate to LimeSurvey
|
||||
*
|
||||
@@ -177,19 +141,6 @@ class ConnectionConfiguration
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password used to authenticate to LimeSurvey
|
||||
*
|
||||
* @param string $password The password used to authenticate to LimeSurvey
|
||||
* @return $this
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information if the "debug" mode is turned on
|
||||
*
|
||||
@@ -200,19 +151,6 @@ class ConnectionConfiguration
|
||||
return $this->debugMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets information if the "debug" mode is turned on
|
||||
*
|
||||
* @param bool $debugMode (optional) If is set to true, the "debug" mode is turned on. Otherwise - turned off.
|
||||
* @return $this
|
||||
*/
|
||||
public function setDebugMode($debugMode = false)
|
||||
{
|
||||
$this->debugMode = $debugMode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information if the SSL certificate verification is turned on
|
||||
*
|
||||
@@ -223,26 +161,6 @@ class ConnectionConfiguration
|
||||
return $this->verifySslCertificate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets information if the SSL certificate verification is turned on
|
||||
*
|
||||
* @param bool $verifySslCertificate (optional) If is set to true, the SSL certificate verification is turned on.
|
||||
* Otherwise - turned off.
|
||||
* @return $this
|
||||
*/
|
||||
public function setVerifySslCertificate($verifySslCertificate = true)
|
||||
{
|
||||
$this->verifySslCertificate = $verifySslCertificate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
* Additional / extra methods (neither getters, nor setters)
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns full url of the LimeSurvey's API.
|
||||
* It's a base url with part related to remote control.
|
||||
@@ -253,4 +171,27 @@ class ConnectionConfiguration
|
||||
{
|
||||
return sprintf('%s/%s', $this->baseUrl, $this->remoteControlUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base url, protocol & domain
|
||||
*
|
||||
* @param string $baseUrl The base url, protocol & domain
|
||||
* @return $this
|
||||
*
|
||||
* @throws InvalidUrlException
|
||||
*/
|
||||
private function setBaseUrl($baseUrl)
|
||||
{
|
||||
if (!Regex::isValidUrl($baseUrl)) {
|
||||
throw new InvalidUrlException($baseUrl);
|
||||
}
|
||||
|
||||
if (Regex::endsWith($baseUrl, '/')) {
|
||||
$baseUrl = substr($baseUrl, 0, strlen($baseUrl) - 1);
|
||||
}
|
||||
|
||||
$this->baseUrl = $baseUrl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user