Skip to content

Commit 4ead6b4

Browse files
rashidspMike Ng
authored and
Mike Ng
committed
feat(isValid): Adds getter to access isValid attribute (#128)
1 parent f11de90 commit 4ead6b4

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Diff for: src/Optimizely/Optimizely.php

+13
Original file line numberDiff line numberDiff line change
@@ -729,4 +729,17 @@ public function getFeatureVariableString($featureFlagKey, $variableKey, $userId,
729729

730730
return $variableValue;
731731
}
732+
733+
/**
734+
* Determine if the instance of the Optimizely client is valid.
735+
* An instance can be deemed invalid if it was not initialized
736+
* properly due to an invalid datafile being passed in.
737+
*
738+
* @return True if the Optimizely instance is valid.
739+
* False if the Optimizely instance is not valid.
740+
*/
741+
public function isValid()
742+
{
743+
return $this->_isValid;
744+
}
732745
}

Diff for: tests/OptimizelyTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ public function setUp()
7676
->getMock();
7777
}
7878

79+
public function testIsValidForInvalidOptimizelyObject()
80+
{
81+
$optlyObject = new Optimizely('Random datafile');
82+
$this->assertFalse($optlyObject->isValid());
83+
}
84+
85+
public function testIsValidForValidOptimizelyObject()
86+
{
87+
$optlyObject = new Optimizely($this->datafile);
88+
$this->assertTrue($optlyObject->isValid());
89+
}
90+
7991
public function testInitValidEventDispatcher()
8092
{
8193
$validDispatcher = new ValidEventDispatcher();

0 commit comments

Comments
 (0)