vendor/flagception/flagception/src/Manager/FeatureManager.php line 58

Open in your IDE?
  1. <?php
  2. namespace Flagception\Manager;
  3. use Flagception\Activator\FeatureActivatorInterface;
  4. use Flagception\Decorator\ContextDecoratorInterface;
  5. use Flagception\Model\Context;
  6. /**
  7.  * Class FeatureManager
  8.  *
  9.  * @author Michel Chowanski <michel.chowanski@bestit-online.de>
  10.  * @package Flagception\Manager
  11.  */
  12. class FeatureManager implements FeatureManagerInterface
  13. {
  14.     /**
  15.      * The feature activator
  16.      *
  17.      * @var FeatureActivatorInterface
  18.      */
  19.     private $activator;
  20.     /**
  21.      * The context decorator
  22.      *
  23.      * @var ContextDecoratorInterface|null
  24.      */
  25.     private $decorator;
  26.     /**
  27.      * FeatureManager constructor.
  28.      *
  29.      * @param FeatureActivatorInterface $activator
  30.      * @param ContextDecoratorInterface|null $decorator
  31.      */
  32.     public function __construct(FeatureActivatorInterface $activatorContextDecoratorInterface $decorator null)
  33.     {
  34.         $this->activator $activator;
  35.         $this->decorator $decorator;
  36.     }
  37.     /**
  38.      * {@inheritdoc}
  39.      */
  40.     public function isActive($nameContext $context null)
  41.     {
  42.         if ($context === null) {
  43.             $context = new Context();
  44.         }
  45.         $context->replace('_feature'$name);
  46.         if ($this->decorator !== null) {
  47.             $context $this->decorator->decorate($context);
  48.         }
  49.         return $this->activator->isActive($name$context);
  50.     }
  51. }