Skip to content

Commit

Permalink
Added the ability to delete multiple keys from session
Browse files Browse the repository at this point in the history
  • Loading branch information
simba77 committed Apr 3, 2022
1 parent 0808025 commit f501e0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions system/src/Http/Session.php
Expand Up @@ -84,10 +84,10 @@ public function has(string $key): bool
}

/**
* @param string $key
* @param array|string $key
* @psalm-suppress NullReference
*/
public function remove(string $key): void
public function remove(array|string $key): void
{
Arr::forget($_SESSION, $key);
}
Expand Down
7 changes: 7 additions & 0 deletions tests/Unit/Http/SessionTest.php
Expand Up @@ -35,6 +35,13 @@ public function testHas(): void
$this->assertTrue($this->session->has('has_test'));
$this->session->remove('has_test');
$this->assertFalse($this->session->has('has_test'));

$this->session->set('has_test', 'value');
$this->session->set('has_test2', 'value');
// Remove multiple keys
$this->session->remove(['has_test', 'has_test2']);
$this->assertFalse($this->session->has('has_test'));
$this->assertFalse($this->session->has('has_test2'));
}

/**
Expand Down

0 comments on commit f501e0d

Please sign in to comment.