Skip to content

Commit e8e7bed

Browse files
committed
Added static setDefaultConnection method
1 parent 31d721a commit e8e7bed

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Container.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ public static function getConnection($name = null)
129129
return static::getInstance()->get($name);
130130
}
131131

132+
/**
133+
* Set the default connection name.
134+
*
135+
* @param string|null $name
136+
*
137+
* @return static
138+
*/
139+
public static function setDefaultConnection($name = null)
140+
{
141+
return static::getInstance()->setDefault($name);
142+
}
143+
132144
/**
133145
* Get the default connection.
134146
*

tests/ContainerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function test_setting_default_connections()
6969
$this->assertInstanceOf(Connection::class, $container->get('other'));
7070
$this->assertInstanceOf(Connection::class, $container->getDefault());
7171

72-
$container->setDefault('non-existent');
72+
Container::setDefaultConnection('non-existent');
7373
$this->expectException(ContainerException::class);
7474
$container->getDefault();
7575
}

0 commit comments

Comments
 (0)