1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 18:34:04 +00:00

Apply fixes from StyleCI

This commit is contained in:
stancl 2020-04-30 18:48:32 +00:00 committed by StyleCI Bot
parent 5d7d208e2f
commit a3a38ee6d2
5 changed files with 16 additions and 10 deletions

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Contracts;
use Stancl\Tenancy\DatabaseConfig;
@ -7,5 +9,6 @@ use Stancl\Tenancy\DatabaseConfig;
interface ManagesDatabaseUsers
{
public function createUser(DatabaseConfig $databaseConfig): void;
public function deleteUser(DatabaseConfig $databaseConfig): void;
}

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy;
use Illuminate\Support\Facades\Hash;
@ -10,7 +12,7 @@ use Stancl\Tenancy\Contracts\TenantDatabaseManager;
use Stancl\Tenancy\Exceptions\DatabaseManagerNotRegisteredException;
class DatabaseConfig
{
{
/** @var Tenant */
public $tenant;
@ -104,7 +106,7 @@ class DatabaseConfig
// and it doesn't exist, we'll go for the default DB template.
if (! array_key_exists($name, config('database.connections'))) {
$name = config('tenancy.database.template_connection') ?? DatabaseManager::$originalDefaultConnectionName;
};
}
return $name;
}

View file

@ -98,7 +98,7 @@ class DatabaseManager
/**
* Check if a tenant can be created.
*
*
* @throws TenantCannotBeCreatedException
* @throws DatabaseManagerNotRegisteredException
* @throws TenantDatabaseAlreadyExistsException
@ -160,7 +160,7 @@ class DatabaseManager
}
foreach ($afterCreating as $item) {
if (is_object($item) && !$item instanceof Closure) {
if (is_object($item) && ! $item instanceof Closure) {
$item->handle($tenant);
} else {
$item($tenant);
@ -170,7 +170,7 @@ class DatabaseManager
/**
* Delete a tenant's database.
*
*
* @throws DatabaseManagerNotRegisteredException
*/
public function deleteDatabase(Tenant $tenant)

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\TenantDatabaseManagers;
use Stancl\Tenancy\Contracts\ManagesDatabaseUsers;
@ -19,7 +21,7 @@ class PermissionControlledMySQLDatabaseManager extends MySQLDatabaseManager impl
$username = $databaseConfig->getUsername();
$hostname = $databaseConfig->connection()['host'];
$password = $databaseConfig->getPassword();
$this->database()->statement("CREATE USER `{$username}`@`{$hostname}` IDENTIFIED BY `{$password}`");
$grants = implode(', ', static::$grants);
@ -44,4 +46,4 @@ class PermissionControlledMySQLDatabaseManager extends MySQLDatabaseManager impl
{
$this->database()->statement("DROP USER IF EXISTS '{$databaseConfig->username}'");
}
}
}

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Tests;
class DatabaseUsersTest extends TestCase
@ -7,18 +9,15 @@ class DatabaseUsersTest extends TestCase
/** @test */
public function users_are_created_when_permission_controlled_mysql_manager_is_used()
{
}
/** @test */
public function correct_grants_are_given_to_the_users()
{
}
/** @test */
public function having_existing_databases_without_users_and_switching_to_permission_controlled_mysql_manager_doesnt_break_existing_dbs()
{
}
}