Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 95b8a16

Browse files
Merge pull request #39 from jenkoian/default-label
Add default label for register_flag too.
2 parents 1a32610 + 1d47f78 commit 95b8a16

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

includes/api/api.general.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @package flagpole
99
*/
1010

11+
use Flagpole\Flag;
1112
use Flagpole\Flagpole;
1213

1314
/**
@@ -23,6 +24,7 @@ function flagpole_register_flag( $args ) {
2324
'enforced' => false,
2425
'description' => '',
2526
'stable' => false,
27+
'label' => Flag::DEFAULT_LABEL
2628

2729
];
2830

includes/class-flag.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
* @package FeatureFlag
2121
*/
2222
class Flag {
23+
/**
24+
* Default label for flags without a label to be grouped under.
25+
*/
26+
const DEFAULT_LABEL = 'All';
2327

2428
/**
2529
* Flags can be enforced. When they are they bypass
@@ -89,11 +93,11 @@ class Flag {
8993
*/
9094
public function __construct( $_key, $_name, $_enforced, $_description, $_stable, $_label ) {
9195
$this->enforced = $_enforced;
92-
$this->name = ( $_name ? $_name : '' );
96+
$this->name = $_name ?: '';
9397
$this->key = $_key;
9498
$this->description = $_description;
9599
$this->stable = $_stable;
96-
$this->label = ( $_label ? $_label : 'All' );
100+
$this->label = $_label ?: self::DEFAULT_LABEL;
97101
}
98102

99103
/**

0 commit comments

Comments
 (0)