Skip to content

Commit

Permalink
Add result() method to export result only
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesChou committed Oct 22, 2018
1 parent dc43ade commit f84842d
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions src/Toggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,30 @@ public function isActive($name, Context $context = null)
return $result;
}

/**
* Import / export result data
*
* @param array|null $data
* @return array
*/
public function result($data = null)
{
if (null === $data) {
return [
'feature' => $this->featuresPreserveResult,
'group' => $this->groupsPreserveResult,
];
}

if (isset($data['feature'])) {
$this->featuresPreserveResult = $data['feature'];
}

if (isset($data['group'])) {
$this->groupsPreserveResult = $data['group'];
}
}

/**
* @param string $name
* @param null|Context $context
Expand Down Expand Up @@ -141,6 +165,17 @@ public function setPreserve($preserve)
return $this;
}

/**
* @param bool $strict
* @return static
*/
public function setStrict($strict)
{
$this->strict = $strict;

return $this;
}

/**
* When $feature on, then call $callable
*
Expand All @@ -158,15 +193,4 @@ public function when($feature, callable $callable, Context $context = null)

return $this;
}

/**
* @param bool $strict
* @return static
*/
public function setStrict($strict)
{
$this->strict = $strict;

return $this;
}
}

0 comments on commit f84842d

Please sign in to comment.