pheature-flags/toggle-crud

View on GitHub
src/Handler/EnableFeature.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\EnableFeature as EnableFeatureCommand;

final class EnableFeature
{
    private FeatureRepository $featureRepository;

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

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

        $feature->enable();

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