diff --git a/src/CacheManager.php b/src/CacheManager.php index daaa8d58..6e37f417 100644 --- a/src/CacheManager.php +++ b/src/CacheManager.php @@ -11,7 +11,7 @@ class CacheManager extends BaseCacheManager $tags = [config('tenancy.cache.tag_base') . tenant('uuid')]; if ($method === "tags") { - if (count($parameters) !== 1) { + if (\count($parameters) !== 1) { throw new \Exception("Method tags() takes exactly 1 argument. {count($parameters)} passed."); } diff --git a/src/DatabaseManager.php b/src/DatabaseManager.php index 94fc1d9f..1064aa5e 100644 --- a/src/DatabaseManager.php +++ b/src/DatabaseManager.php @@ -2,7 +2,6 @@ namespace Stancl\Tenancy; -use Illuminate\Support\Facades\DB; use Stancl\Tenancy\Jobs\QueuedTenantDatabaseCreator; use Stancl\Tenancy\Jobs\QueuedTenantDatabaseDeleter; use Illuminate\Database\DatabaseManager as BaseDatabaseManager; diff --git a/src/TenancyServiceProvider.php b/src/TenancyServiceProvider.php index f613184b..127da603 100644 --- a/src/TenancyServiceProvider.php +++ b/src/TenancyServiceProvider.php @@ -12,7 +12,6 @@ use Illuminate\Support\ServiceProvider; use Stancl\Tenancy\Commands\TenantList; use Stancl\Tenancy\Interfaces\StorageDriver; use Stancl\Tenancy\Interfaces\ServerConfigManager; -use Stancl\Tenancy\StorageDrivers\RedisStorageDriver; class TenancyServiceProvider extends ServiceProvider { diff --git a/src/TenantManager.php b/src/TenantManager.php index 1e105c1f..f305b080 100644 --- a/src/TenantManager.php +++ b/src/TenantManager.php @@ -2,7 +2,6 @@ namespace Stancl\Tenancy; -use Illuminate\Support\Facades\Redis; use Stancl\Tenancy\Interfaces\StorageDriver; use Stancl\Tenancy\Traits\BootstrapsTenancy; use Illuminate\Contracts\Foundation\Application; @@ -166,7 +165,7 @@ class TenantManager public function getDatabaseName($tenant = []): string { $tenant = $tenant ?: $this->tenant; - return config('tenancy.database.prefix') . $tenant['uuid'] . config('tenancy.database.suffix'); + return $this->app['config']['tenancy.database.prefix'] . $tenant['uuid'] . $this->app['config']['tenancy.database.suffix']; } /** @@ -233,7 +232,7 @@ class TenantManager { $uuid = $uuid ?: $this->tenant['uuid']; - if (is_array($key)) { + if (\is_array($key)) { return $this->jsonDecodeArrayValues($this->storage->getMany($uuid, $key)); } @@ -250,7 +249,7 @@ class TenantManager */ public function put($key, $value = null, string $uuid = null) { - if (is_null($uuid)) { + if (\is_null($uuid)) { if (! isset($this->tenant['uuid'])) { throw new \Exception("No UUID supplied (and no tenant is currently identified)."); } @@ -264,11 +263,11 @@ class TenantManager $target = []; // black hole } - if (! is_null($value)) { + if (! \is_null($value)) { return $target[$key] = json_decode($this->storage->put($uuid, $key, json_encode($value)), true); } - if (! is_array($key)) { + if (! \is_array($key)) { throw new \Exception("No value supplied for key $key."); } @@ -310,7 +309,7 @@ class TenantManager */ public function __invoke($attribute) { - if (is_null($attribute)) { + if (\is_null($attribute)) { return $this->tenant; } diff --git a/src/TenantRouteServiceProvider.php b/src/TenantRouteServiceProvider.php index 92897780..4ea77402 100644 --- a/src/TenantRouteServiceProvider.php +++ b/src/TenantRouteServiceProvider.php @@ -9,7 +9,7 @@ class TenantRouteServiceProvider extends RouteServiceProvider { public function map() { - if (! in_array(request()->getHost(), $this->app['config']['tenancy.exempt_domains'] ?? []) + if (! \in_array(request()->getHost(), $this->app['config']['tenancy.exempt_domains'] ?? []) && file_exists(base_path('routes/tenant.php'))) { Route::middleware(['web', 'tenancy']) ->namespace($this->app['config']['tenant_route_namespace'] ?? 'App\Http\Controllers') diff --git a/src/Traits/BootstrapsTenancy.php b/src/Traits/BootstrapsTenancy.php index 20809a4c..d09be0ff 100644 --- a/src/Traits/BootstrapsTenancy.php +++ b/src/Traits/BootstrapsTenancy.php @@ -26,7 +26,7 @@ trait BootstrapsTenancy public function setPhpRedisPrefix($connections = ['default']) { foreach ($connections as $connection) { - $prefix = config('tenancy.redis.prefix_base') . $this->tenant['uuid']; + $prefix = $this->app['config']['tenancy.redis.prefix_base'] . $this->tenant['uuid']; $client = Redis::connection($connection)->client(); $client->setOption($client::OPT_PREFIX, $prefix); }