vendor/flagception/flagception-bundle/src/Activator/TraceableChainActivator.php line 31

Open in your IDE?
  1. <?php
  2. namespace Flagception\Bundle\FlagceptionBundle\Activator;
  3. use Flagception\Activator\ChainActivator;
  4. use Flagception\Model\Context;
  5. /**
  6.  * Decorate an activator and make it traceable
  7.  *
  8.  * @author Michel Chowanski <michel.chowanski@bestit-online.de>
  9.  * @package Flagception\Bundle\FlagceptionBundle\Activator
  10.  */
  11. class TraceableChainActivator extends ChainActivator
  12. {
  13.     /**
  14.      * Trace of this chain activator
  15.      *
  16.      * @var array
  17.      */
  18.     private $trace = [];
  19.     /**
  20.      * {@inheritdoc}
  21.      */
  22.     public function isActive($nameContext $context): bool
  23.     {
  24.         $stack = [];
  25.         $result false;
  26.         foreach ($this->getActivators() as $activator) {
  27.             if ($activator->isActive($name$context) === true) {
  28.                 $result $stack[$activator->getName()] = true;
  29.                 break;
  30.             }
  31.             $stack[$activator->getName()] = $result;
  32.         }
  33.         $this->trace[] = [
  34.             'feature' => $name,
  35.             'context' => $context,
  36.             'result' => $result,
  37.             'stack' => $stack
  38.         ];
  39.         return $result;
  40.     }
  41.     /**
  42.      * Get trace
  43.      *
  44.      * @return array
  45.      */
  46.     public function getTrace()
  47.     {
  48.         return $this->trace;
  49.     }
  50. }