|
2 | 2 |
|
3 | 3 | namespace Bugsnag; |
4 | 4 |
|
| 5 | +use Bugsnag\Internal\FeatureFlagDelegate; |
5 | 6 | use InvalidArgumentException; |
6 | 7 |
|
7 | | -class Configuration |
| 8 | +class Configuration implements FeatureDataStore |
8 | 9 | { |
9 | 10 | /** |
10 | 11 | * The default endpoint for event notifications. |
@@ -84,7 +85,7 @@ class Configuration |
84 | 85 | */ |
85 | 86 | protected $notifier = [ |
86 | 87 | 'name' => 'Bugsnag PHP (Official)', |
87 | | - 'version' => '3.27.0', |
| 88 | + 'version' => '3.28.0', |
88 | 89 | 'url' => 'https://bugsnag.com', |
89 | 90 | ]; |
90 | 91 |
|
@@ -116,6 +117,13 @@ class Configuration |
116 | 117 | */ |
117 | 118 | protected $metaData = []; |
118 | 119 |
|
| 120 | + /** |
| 121 | + * The associated feature flags. |
| 122 | + * |
| 123 | + * @var FeatureFlagDelegate |
| 124 | + */ |
| 125 | + private $featureFlags; |
| 126 | + |
119 | 127 | /** |
120 | 128 | * The error reporting level. |
121 | 129 | * |
@@ -196,6 +204,7 @@ public function __construct($apiKey) |
196 | 204 |
|
197 | 205 | $this->apiKey = $apiKey; |
198 | 206 | $this->fallbackType = php_sapi_name(); |
| 207 | + $this->featureFlags = new FeatureFlagDelegate(); |
199 | 208 |
|
200 | 209 | // Add PHP runtime version to device data |
201 | 210 | $this->mergeDeviceData(['runtimeVersions' => ['php' => phpversion()]]); |
@@ -588,6 +597,64 @@ public function getMetaData() |
588 | 597 | return $this->metaData; |
589 | 598 | } |
590 | 599 |
|
| 600 | + /** |
| 601 | + * Add a single feature flag to all future reports. |
| 602 | + * |
| 603 | + * @param string $name |
| 604 | + * @param string|null $variant |
| 605 | + * |
| 606 | + * @return void |
| 607 | + */ |
| 608 | + public function addFeatureFlag($name, $variant = null) |
| 609 | + { |
| 610 | + $this->featureFlags->add($name, $variant); |
| 611 | + } |
| 612 | + |
| 613 | + /** |
| 614 | + * Add multiple feature flags to all future reports. |
| 615 | + * |
| 616 | + * @param FeatureFlag[] $featureFlags |
| 617 | + * @phpstan-param list<FeatureFlag> $featureFlags |
| 618 | + * |
| 619 | + * @return void |
| 620 | + */ |
| 621 | + public function addFeatureFlags(array $featureFlags) |
| 622 | + { |
| 623 | + $this->featureFlags->merge($featureFlags); |
| 624 | + } |
| 625 | + |
| 626 | + /** |
| 627 | + * Remove the feature flag with the given name from all future reports. |
| 628 | + * |
| 629 | + * @param string $name |
| 630 | + * |
| 631 | + * @return void |
| 632 | + */ |
| 633 | + public function clearFeatureFlag($name) |
| 634 | + { |
| 635 | + $this->featureFlags->remove($name); |
| 636 | + } |
| 637 | + |
| 638 | + /** |
| 639 | + * Remove all feature flags from all future reports. |
| 640 | + * |
| 641 | + * @return void |
| 642 | + */ |
| 643 | + public function clearFeatureFlags() |
| 644 | + { |
| 645 | + $this->featureFlags->clear(); |
| 646 | + } |
| 647 | + |
| 648 | + /** |
| 649 | + * @internal |
| 650 | + * |
| 651 | + * @return FeatureFlagDelegate |
| 652 | + */ |
| 653 | + public function getFeatureFlagsCopy() |
| 654 | + { |
| 655 | + return clone $this->featureFlags; |
| 656 | + } |
| 657 | + |
591 | 658 | /** |
592 | 659 | * Set Bugsnag's error reporting level. |
593 | 660 | * |
|
0 commit comments