From 51fc3c7706c9b70e9e0841449ea4852c6f774067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Sun, 8 Sep 2019 11:35:05 +0200 Subject: [PATCH] Exceptions --- src/TenantManagerv2.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/TenantManagerv2.php b/src/TenantManagerv2.php index ee22f204..a5d5e387 100644 --- a/src/TenantManagerv2.php +++ b/src/TenantManagerv2.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Stancl\Tenancy; use Illuminate\Foundation\Application; +use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedException; /** * @internal Class is subject to breaking changes in minor and patch versions. @@ -19,14 +20,14 @@ class TenantManagerv2 protected $tenant; /** @var Application */ - private $app; + protected $app; /** @var Contracts\StorageDriver */ - private $storage; + protected $storage; // todo event "listeners" instead of "callbacks" /** @var callable[][] */ - public $callbacks = []; + protected $callbacks = []; public function __construct(Application $app, Contracts\StorageDriver $storage) { @@ -50,7 +51,6 @@ class TenantManagerv2 return $this; } - // todo @throws public function init(string $domain): self { $this->initializeTenancy($this->findByDomain($domain)); @@ -58,7 +58,6 @@ class TenantManagerv2 return $this; } - // todo @throws public function initById(string $id): self { $this->initializeTenancy($this->find($id)); @@ -66,13 +65,25 @@ class TenantManagerv2 return $this; } - // todo @throws + /** + * Identify a tenant using id. + * + * @param string $id + * @return Tenant + * @throws TenantCouldNotBeIdentifiedException + */ public function find(string $id): Tenant { return $this->storage->findById($id); } - // todo @throws + /** + * Identify a tenant using id. + * + * @param string $id + * @return Tenant + * @throws TenantCouldNotBeIdentifiedException + */ public function findByDomain(string $domain): Tenant { return $this->storage->findByDomain($domain);