Skip to content

Commit

Permalink
Configuration options are supplemented
Browse files Browse the repository at this point in the history
  • Loading branch information
batumibiz committed Jan 21, 2024
1 parent 4b76968 commit 97d9784
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/SessionMiddlewareFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@ class SessionMiddlewareFactory
*/
public function __invoke(ContainerInterface $container): SessionMiddleware
{
/** @var ConfigInterface $configContainer */
$configContainer = $container->get(ConfigInterface::class);
$config = (array) $configContainer->get('session', []);
if ($container->has(ConfigInterface::class)) {
/** @var ConfigInterface $configContainer */
$configContainer = $container->get(ConfigInterface::class);
$config = (array) $configContainer->get('session', []);
} elseif ($container->has('config')) {
$configArray = (array) $container->get('config');
$config = $configArray['session'] ?? [];

Check warning on line 26 in src/SessionMiddlewareFactory.php

View workflow job for this annotation

GitHub Actions / Static Analysis

MixedAssignment

src/SessionMiddlewareFactory.php:26:13: MixedAssignment: Unable to determine the type that $config is being assigned to (see https://psalm.dev/032)
} else {
$config = [];
}

$session = new SessionHandler(
$container->get(PDO::class),
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/SessionMiddlewareFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ private function getContainer(array $options): ContainerInterface
->willReturn($options);

$container = $this->createMock(ContainerInterface::class);
$container
->method('has')
->with(ConfigInterface::class)
->willReturn(true);
$container
->method('get')
->willReturnCallback(
Expand Down

0 comments on commit 97d9784

Please sign in to comment.