Inheritance: implements Zumba\Swivel\ManagerInterface, use trait Psr\Log\LoggerAwareTrait
Exemple #1
0
 public function testSetBucketReturnsManager()
 {
     $manager = new Manager(new Config());
     $map = $this->getMock('Zumba\\Swivel\\Map');
     $bucket = $this->getMock('Zumba\\Swivel\\Bucket', null, [$map]);
     $this->assertInstanceOf('Zumba\\Swivel\\Manager', $manager->setBucket($bucket));
 }
Exemple #2
0
 /**
  * Used to set the bucket index before loading swivel.
  *
  * @param integer $index Number between 1 and 10
  * @return void
  * @throws InvalidArgumentException if $index is not valid
  */
 public function setBucketIndex($index)
 {
     if (!is_numeric($index) || $index < 1 || $index > 10) {
         throw new InvalidArgumentException("{$index} is not a valid bucket index.");
     }
     if (empty($this->manager)) {
         $this->options['BucketIndex'] = $index;
     } else {
         $config = $this->getConfig();
         $config->setBucketIndex($index);
         $this->manager->setBucket($config->getBucket());
     }
 }
Exemple #3
0
 /**
  * @dataProvider falseyValueProvider
  */
 public function testFalseyValuesAllowed($falseyValue)
 {
     $swivel = new Manager(new Config($this->map, 10));
     $this->assertSame($falseyValue, $swivel->returnValue('OldFeature.Legacy', $falseyValue));
 }
Exemple #4
0
 /**
  * Create a new Builder instance
  *
  * @param string $slug
  * @return \Zumba\Swivel\Builder
  * @see \Zumba\Swivel\ManagerInterface
  */
 public function forFeature($slug)
 {
     $feature = parent::forFeature($slug);
     $this->features[$slug] = $feature;
     return $feature;
 }
 /**
  * Syntactic sugar for creating simple feature toggles (ternary style)
  *
  * @param string $slug
  * @param mixed $a
  * @param mixed $b
  * @return mixed
  */
 public function invoke($slug, $a, $b = null)
 {
     return $this->loader->getManager()->invoke($slug, $a, $b);
 }