Skip to content

Commit

Permalink
Merge 4cff7cb into fbf5499
Browse files Browse the repository at this point in the history
  • Loading branch information
rashidsp committed Sep 5, 2018
2 parents fbf5499 + 4cff7cb commit f02610c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Optimizely/Optimizely.php
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,19 @@ public function getFeatureVariableString($featureFlagKey, $variableKey, $userId,
return $variableValue;
}

/**
* Determine if the instance of the Optimizely client is valid.
* An instance can be deemed invalid if it was not initialized
* properly due to an invalid datafile being passed in.
*
* @return True if the Optimizely instance is valid.
* False if the Optimizely instance is not valid.
*/
public function isValid()
{
return $this->_isValid;
}

/**
* Calls Validator::validateNonEmptyString for each value in array
* Logs for each invalid value
Expand Down
12 changes: 12 additions & 0 deletions tests/OptimizelyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ public function setUp()
->getMock();
}

public function testIsValidForInvalidOptimizelyObject()
{
$optlyObject = new Optimizely('Random datafile');
$this->assertFalse($optlyObject->isValid());
}

public function testIsValidForValidOptimizelyObject()
{
$optlyObject = new Optimizely($this->datafile);
$this->assertTrue($optlyObject->isValid());
}

public function testInitValidEventDispatcher()
{
$validDispatcher = new ValidEventDispatcher();
Expand Down

0 comments on commit f02610c

Please sign in to comment.