From e919c6e25b8a6230f9a524632536672caa176d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Mon, 28 Jan 2019 18:34:26 +0100 Subject: [PATCH] Minor refactor --- src/TenantManager.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/TenantManager.php b/src/TenantManager.php index b703eb08..75568367 100644 --- a/src/TenantManager.php +++ b/src/TenantManager.php @@ -22,14 +22,14 @@ class TenantManager * * @var StorageDriver */ - public $storage; + private $storage; /** * Database manager. * * @var DatabaseManager */ - public $database; + private $database; /** * Current tenant. @@ -225,13 +225,18 @@ class TenantManager */ public function put($key, $value = null, string $uuid = null) { - $uuid = $uuid ?: $this->tenant['uuid']; - - // If $uuid is the uuid of the current tenant, put - // the value into the $this->tenant array as well. - $target = []; // black hole - if (($this->tenant['uuid'] ?? null) === $uuid) { + if (is_null($uuid)) { + if (! isset($this->tenant['uuid'])) { + throw new \Exception("No UUID supplied (and no tenant is currently identified)."); + } + + $uuid = $this->tenant['uuid']; + + // If $uuid is the uuid of the current tenant, put + // the value into the $this->tenant array as well. $target = &$this->tenant; + } else { + $target = []; // black hole } if (! is_null($value)) {