Skip to content

Commit 7f23189

Browse files
committed
Deduplicate getEnvironment()
1 parent 79ec506 commit 7f23189

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

src/Defaults.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static function instance()
1919

2020
public function environment()
2121
{
22-
return ( getenv('WP_ENV') ?: ( defined( 'WP_ENV' ) ? WP_ENV : null ) );
22+
return \Rollbar\Wordpress\Plugin::getEnvironment();
2323
}
2424

2525
public function root()

src/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private function initSettings() {
5353
Settings::init();
5454
}
5555

56-
private function getEnvironment()
56+
public static function getEnvironment()
5757
{
5858
return ( getenv('WP_ENV') ?: ( defined( 'WP_ENV' ) ? WP_ENV : null ) );
5959
}

src/UI.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,13 @@ public static function status($settings)
217217
</p>
218218
<?php
219219
}
220-
221-
public static function getEnvironment()
222-
{
223-
return ( getenv('WP_ENV') ?: ( defined( 'WP_ENV' ) ? WP_ENV : null ) );
224-
}
225220

226221
public static function environmentSettingNote()
227222
{
223+
$env = \Rollbar\Wordpress\Plugin::getEnvironment();
224+
228225
$output =
229-
'<p><code>WP_ENV</code> environment variable: <code> ' . self::getEnvironment() . ' </code></p>' .
226+
'<p><code>WP_ENV</code> environment variable: <code>' . $env . '</code></p>' .
230227
'<p><small><strong>Rollbar for Wordpress honors the WP_ENV environment variable.</strong> ' .
231228
'If the <code>environment</code> setting is not specified here, it will take ' .
232229
'precendence over the default value.</strong></small></p>';

0 commit comments

Comments
 (0)