Changeset View
Changeset View
Standalone View
Standalone View
src/SitesRepository/Site.php
- This file was added.
<?php | |||||
namespace Nasqueron\SAAS\PhpBB\SitesRepository; | |||||
class Site { | |||||
/// | |||||
/// Private members | |||||
/// | |||||
/** | |||||
* @var string | |||||
*/ | |||||
private $id; | |||||
/** | |||||
* @var string | |||||
*/ | |||||
private $host; | |||||
/** | |||||
* @var string | |||||
*/ | |||||
private $databaseUser; | |||||
/** | |||||
* @var string | |||||
*/ | |||||
private $databasePassword; | |||||
/** | |||||
* @var string | |||||
*/ | |||||
private $databasePrefix; | |||||
/** | |||||
* @var bool | |||||
*/ | |||||
private $active; | |||||
/// | |||||
/// Getters and setters | |||||
/// | |||||
public function getId () : string { | |||||
return $this->id; | |||||
} | |||||
public function setId (string $id) : Site { | |||||
$this->id = $id; | |||||
if (!$this->hasValidIdentifiant()) { | |||||
throw new \InvalidArgumentException( | |||||
"ID must only contain letters, digits and underscore." | |||||
); | |||||
} | |||||
return $this; | |||||
} | |||||
public function getHost () : string { | |||||
return $this->host; | |||||
} | |||||
public function setHost (string $host) : Site { | |||||
$this->host = $host; | |||||
return $this; | |||||
} | |||||
public function getDatabaseUser () : string { | |||||
return $this->databaseUser; | |||||
} | |||||
public function setDatabaseUser (string $databaseUser) : Site { | |||||
$this->databaseUser = $databaseUser; | |||||
return $this; | |||||
} | |||||
public function getDatabasePassword () : string { | |||||
return $this->databasePassword; | |||||
} | |||||
public function setDatabasePassword (string $databasePassword) : Site { | |||||
$this->databasePassword = $databasePassword; | |||||
return $this; | |||||
} | |||||
public function getDatabasePrefix () : string { | |||||
return $this->databasePrefix; | |||||
} | |||||
public function setDatabasePrefix (string $databasePrefix) : Site { | |||||
$this->databasePrefix = $databasePrefix; | |||||
return $this; | |||||
} | |||||
public function isActive () : bool { | |||||
return $this->active; | |||||
} | |||||
public function setActive (bool $active) : Site { | |||||
$this->active = $active; | |||||
return $this; | |||||
} | |||||
/// | |||||
/// Identifiant validation | |||||
/// | |||||
const VALID_ID_REGEXP = "/^[A-Za-z0-9_]+$/"; | |||||
private function hasValidIdentifiant () : bool { | |||||
return (bool)preg_match(self::VALID_ID_REGEXP, $this->id); | |||||
} | |||||
} |
Nasqueron DevCentral · If it had been much bigger the moon would have had a core of ice. · Powered by Phabricator