1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 20:34:03 +00:00

Minor refactor

This commit is contained in:
Samuel Štancl 2019-01-28 18:34:26 +01:00
parent 7ce9613a68
commit e919c6e25b

View file

@ -22,14 +22,14 @@ class TenantManager
* *
* @var StorageDriver * @var StorageDriver
*/ */
public $storage; private $storage;
/** /**
* Database manager. * Database manager.
* *
* @var DatabaseManager * @var DatabaseManager
*/ */
public $database; private $database;
/** /**
* Current tenant. * Current tenant.
@ -225,13 +225,18 @@ class TenantManager
*/ */
public function put($key, $value = null, string $uuid = null) public function put($key, $value = null, string $uuid = null)
{ {
$uuid = $uuid ?: $this->tenant['uuid']; if (is_null($uuid)) {
if (! isset($this->tenant['uuid'])) {
throw new \Exception("No UUID supplied (and no tenant is currently identified).");
}
// If $uuid is the uuid of the current tenant, put $uuid = $this->tenant['uuid'];
// the value into the $this->tenant array as well.
$target = []; // black hole // If $uuid is the uuid of the current tenant, put
if (($this->tenant['uuid'] ?? null) === $uuid) { // the value into the $this->tenant array as well.
$target = &$this->tenant; $target = &$this->tenant;
} else {
$target = []; // black hole
} }
if (! is_null($value)) { if (! is_null($value)) {