Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/LaunchDarkly/EvalResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace LaunchDarkly;

class EvalResult
{
private $_variation = null;
private $_value = null;
/** @var array */
private $_prerequisiteEvents = [];

/**
* EvalResult constructor.
* @param null $value
* @param array $prerequisiteEvents
*/
public function __construct($variation, $value, array $prerequisiteEvents)
{
$this->_variation = $variation;
$this->_value = $value;
$this->_prerequisiteEvents = $prerequisiteEvents;
}

/**
* @return int
*/
public function getVariation()
{
return $this->_variation;
}

/**
* @return null
*/
public function getValue()
{
return $this->_value;
}

/**
* @return array
*/
public function getPrerequisiteEvents()
{
return $this->_prerequisiteEvents;
}
}
194 changes: 0 additions & 194 deletions src/LaunchDarkly/FeatureFlag.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,197 +223,3 @@ public function isDeleted()
return $this->_deleted;
}
}

class EvalResult
{
private $_variation = null;
private $_value = null;
/** @var array */
private $_prerequisiteEvents = [];

/**
* EvalResult constructor.
* @param null $value
* @param array $prerequisiteEvents
*/
public function __construct($variation, $value, array $prerequisiteEvents)
{
$this->_variation = $variation;
$this->_value = $value;
$this->_prerequisiteEvents = $prerequisiteEvents;
}

/**
* @return int
*/
public function getVariation()
{
return $this->_variation;
}

/**
* @return null
*/
public function getValue()
{
return $this->_value;
}

/**
* @return array
*/
public function getPrerequisiteEvents()
{
return $this->_prerequisiteEvents;
}
}

class WeightedVariation
{
/** @var int */
private $_variation = null;
/** @var int */
private $_weight = null;

private function __construct($variation, $weight)
{
$this->_variation = $variation;
$this->_weight = $weight;
}

public static function getDecoder()
{
return function ($v) {
return new WeightedVariation($v['variation'], $v['weight']);
};
}

/**
* @return int
*/
public function getVariation()
{
return $this->_variation;
}

/**
* @return int
*/
public function getWeight()
{
return $this->_weight;
}
}

class Target
{
/** @var string[] */
private $_values = array();
/** @var int */
private $_variation = null;

protected function __construct(array $values, $variation)
{
$this->_values = $values;
$this->_variation = $variation;
}

public static function getDecoder()
{
return function ($v) {
return new Target($v['values'], $v['variation']);
};
}

/**
* @return \string[]
*/
public function getValues()
{
return $this->_values;
}

/**
* @return int
*/
public function getVariation()
{
return $this->_variation;
}
}

class Prerequisite
{
/** @var string */
private $_key = null;
/** @var int */
private $_variation = null;

protected function __construct($key, $variation)
{
$this->_key = $key;
$this->_variation = $variation;
}

public static function getDecoder()
{
return function ($v) {
return new Prerequisite($v['key'], $v['variation']);
};
}

/**
* @return string
*/
public function getKey()
{
return $this->_key;
}

/**
* @return int
*/
public function getVariation()
{
return $this->_variation;
}
}

class Rollout
{
/** @var WeightedVariation[] */
private $_variations = array();
/** @var string */
private $_bucketBy = null;

protected function __construct(array $variations, $bucketBy)
{
$this->_variations = $variations;
$this->_bucketBy = $bucketBy;
}

public static function getDecoder()
{
return function ($v) {
return new Rollout(
array_map(WeightedVariation::getDecoder(), $v['variations']),
isset($v['bucketBy']) ? $v['bucketBy'] : null);
};
}

/**
* @return WeightedVariation[]
*/
public function getVariations()
{
return $this->_variations;
}

/**
* @return string
*/
public function getBucketBy()
{
return $this->_bucketBy;
}
}
9 changes: 9 additions & 0 deletions src/LaunchDarkly/InvalidSDKKeyException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
namespace LaunchDarkly;

/**
* Used internally.
*/
class InvalidSDKKeyException extends \Exception
{
}
7 changes: 0 additions & 7 deletions src/LaunchDarkly/LDClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
use Monolog\Logger;
use Psr\Log\LoggerInterface;

/**
* Used internally.
*/
class InvalidSDKKeyException extends \Exception
{
}

/**
* A client for the LaunchDarkly API.
*/
Expand Down
39 changes: 39 additions & 0 deletions src/LaunchDarkly/Prerequisite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
namespace LaunchDarkly;

class Prerequisite
{
/** @var string */
private $_key = null;
/** @var int */
private $_variation = null;

protected function __construct($key, $variation)
{
$this->_key = $key;
$this->_variation = $variation;
}

public static function getDecoder()
{
return function ($v) {
return new Prerequisite($v['key'], $v['variation']);
};
}

/**
* @return string
*/
public function getKey()
{
return $this->_key;
}

/**
* @return int
*/
public function getVariation()
{
return $this->_variation;
}
}
41 changes: 41 additions & 0 deletions src/LaunchDarkly/Rollout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
namespace LaunchDarkly;

class Rollout
{
/** @var WeightedVariation[] */
private $_variations = array();
/** @var string */
private $_bucketBy = null;

protected function __construct(array $variations, $bucketBy)
{
$this->_variations = $variations;
$this->_bucketBy = $bucketBy;
}

public static function getDecoder()
{
return function ($v) {
return new Rollout(
array_map(WeightedVariation::getDecoder(), $v['variations']),
isset($v['bucketBy']) ? $v['bucketBy'] : null);
};
}

/**
* @return WeightedVariation[]
*/
public function getVariations()
{
return $this->_variations;
}

/**
* @return string
*/
public function getBucketBy()
{
return $this->_bucketBy;
}
}
Loading