pheature-flags/toggle-crud

View on GitHub
src/Handler/RemoveFeature.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

declare(strict_types=1);

namespace Pheature\Crud\Toggle\Handler;

use Pheature\Core\Toggle\Write\FeatureRepository;
use Pheature\Crud\Toggle\Command\RemoveFeature as RemoveFeatureCommand;

final class RemoveFeature
{
    private FeatureRepository $featureRepository;

    public function __construct(FeatureRepository $repository)
    {
        $this->featureRepository = $repository;
    }

    public function handle(RemoveFeatureCommand $command): void
    {
        $feature = $this->featureRepository->get($command->featureId());

        $feature->remove();

        $this->featureRepository->remove($feature);
    }
}