Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ResetUserPreferencesHandler | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| handle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Core\Preference\Application\Command; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | use App\Core\Preference\Domain\Repository\UserPreferenceRepositoryInterface; |
| 12 | |
| 13 | /** |
| 14 | * Command Handler for resetting user preferences. |
| 15 | * |
| 16 | * @package App\Core\Preference\Application\Command |
| 17 | */ |
| 18 | final readonly class ResetUserPreferencesHandler |
| 19 | { |
| 20 | /** |
| 21 | * ResetUserPreferencesHandler constructor. |
| 22 | * |
| 23 | * @param UserPreferenceRepositoryInterface $repository Preference repository. |
| 24 | */ |
| 25 | public function __construct( |
| 26 | private UserPreferenceRepositoryInterface $repository, |
| 27 | ) { |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Handles ResetUserPreferencesCommand execution. |
| 32 | * |
| 33 | * @param ResetUserPreferencesCommand $command Command with scope and optional key. |
| 34 | * @return int Number of deleted preference records. |
| 35 | */ |
| 36 | public function handle(ResetUserPreferencesCommand $command): int |
| 37 | { |
| 38 | return $this->repository->deleteByScope($command->scope, $command->key); |
| 39 | } |
| 40 | } |