2014-03-20 16:18:35 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Server;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Model Class holding the Server Config
|
|
|
|
*
|
2014-05-02 17:50:30 +02:00
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
|
|
|
* @copyright 2014 ManiaControl Team
|
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2014-03-20 16:18:35 +01:00
|
|
|
*/
|
|
|
|
class Config {
|
|
|
|
/*
|
2014-04-12 12:14:37 +02:00
|
|
|
* Public Properties
|
2014-03-20 16:18:35 +01:00
|
|
|
*/
|
|
|
|
public $id = null;
|
|
|
|
public $host = null;
|
|
|
|
public $port = null;
|
|
|
|
public $login = null;
|
|
|
|
public $pass = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new Server Config Instance
|
|
|
|
*
|
2014-05-02 17:50:30 +02:00
|
|
|
* @param string $id Config Id
|
|
|
|
* @param string $host Server Ip
|
|
|
|
* @param string $port Server Port
|
2014-03-20 16:18:35 +01:00
|
|
|
* @param string $login XmlRpc Login
|
2014-05-02 17:50:30 +02:00
|
|
|
* @param string $pass XmlRpc Password
|
2014-03-20 16:18:35 +01:00
|
|
|
*/
|
|
|
|
public function __construct($id = null, $host = null, $port = null, $login = null, $pass = null) {
|
2014-05-27 08:57:26 +02:00
|
|
|
$this->id = (string)$id;
|
|
|
|
$this->host = (string)$host;
|
|
|
|
$this->port = (int)$port;
|
|
|
|
$this->login = (string)$login;
|
|
|
|
$this->pass = (string)$pass;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Validate the Config Data
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function validate() {
|
|
|
|
$invalid = false;
|
|
|
|
if (!$this->host) {
|
|
|
|
$invalid = true;
|
|
|
|
} else if (!$this->port || $this->port === 'port') {
|
|
|
|
$invalid = true;
|
|
|
|
}
|
|
|
|
if ($invalid) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2014-03-20 16:18:35 +01:00
|
|
|
}
|
|
|
|
}
|