Skip to content

Commit 9bfd50c

Browse files
committed
Moved Tugboat to separate environment.
1 parent 4d8590e commit 9bfd50c

File tree

4 files changed

+52
-18
lines changed

4 files changed

+52
-18
lines changed

src/Environment.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Davereid\DrupalEnvironment\Environment\GitHubWorkflow;
99
use Davereid\DrupalEnvironment\Environment\GitLabCi;
1010
use Davereid\DrupalEnvironment\Environment\Pantheon;
11+
use Davereid\DrupalEnvironment\Environment\Tugboat;
1112

1213
/**
1314
* Helpers for working with the Drupal environment.
@@ -35,6 +36,7 @@ class Environment
3536
public const CLASSES = [
3637
'isAcquia' => Acquia::class,
3738
'isPantheon' => Pantheon::class,
39+
'isTugboat' => Tugboat::class,
3840
'isGitHubWorkflow' => GitHubWorkflow::class,
3941
'isGitLabCi' => GitLabCi::class,
4042
'isCircleCi' => CircleCi::class,
@@ -119,19 +121,6 @@ public static function isLando(): bool
119121
return (bool)static::get('LANDO_INFO');
120122
}
121123

122-
/**
123-
* Determine if this is a Tugboat environment.
124-
*
125-
* @return bool
126-
* TRUE if this is a Tugboat environment.
127-
*
128-
* @todo Should this be its own environment class?
129-
*/
130-
public static function isTugboat(): bool
131-
{
132-
return static::getEnvironment() === 'tugboat';
133-
}
134-
135124
/**
136125
* Determines whether the current request is a command-line one.
137126
*

src/Environment/DefaultEnvironment.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Davereid\DrupalEnvironment\Environment;
44

5+
use Davereid\DrupalEnvironment\Environment;
6+
57
/**
68
* The standard environment.
79
*/
@@ -36,6 +38,13 @@ class DefaultEnvironment
3638
*/
3739
public const DEVELOPMENT = 'dev';
3840

41+
/**
42+
* The default preview environment name.
43+
*
44+
* @var string
45+
*/
46+
public const PREVIEW = 'preview';
47+
3948
/**
4049
* The default CI environment name.
4150
*
@@ -71,7 +80,7 @@ public static function get(string $name)
7180
*/
7281
public static function getEnvironment(): string
7382
{
74-
return Environment::get(static::ENVIRONMENT_NAME);
83+
return static::get(static::ENVIRONMENT_NAME);
7584
}
7685

7786
/**
@@ -115,7 +124,7 @@ public static function isDevelopment(): bool
115124
*/
116125
public static function isPreview(): bool
117126
{
118-
return Environment::isTugboat();
127+
return static::getEnvironment() === static::PREVIEW;
119128
}
120129

121130
/**
@@ -129,6 +138,17 @@ public static function isCi(): bool
129138
return static::getEnvironment() === static::CI;
130139
}
131140

141+
/**
142+
* Determine if this is a local environment.
143+
*
144+
* @return bool
145+
* TRUE if this is local.
146+
*/
147+
public static function isLocal(): bool
148+
{
149+
return Environment::isLocal();
150+
}
151+
132152
/**
133153
* Get the environment_indicator configuration. for this environment.
134154
*
@@ -166,7 +186,7 @@ public static function getIndicatorConfig(): ?array {
166186
'fg_color' => '#990055',
167187
];
168188
}
169-
if (Environment::isLocal()) {
189+
if (static::isLocal()) {
170190
return [
171191
'name' => 'Local',
172192
'bg_color' => '#ffffff',

src/Environment/Pantheon.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Davereid\DrupalEnvironment\Environment;
44

5-
65
/**
76
* The Pantheon environment specifics.
87
*
@@ -44,7 +43,7 @@ public static function isMultidev(): bool
4443
&& !static::isStaging()
4544
&& !static::isDevelopment()
4645
&& !static::isCi()
47-
&& !Environment::isLocal();
46+
&& !static::isLocal();
4847
}
4948

5049
}

src/Environment/Tugboat.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Davereid\DrupalEnvironment\Environment;
4+
5+
/**
6+
* The Tugboat environment specifics.
7+
*
8+
* @see https://docs.tugboatqa.com/reference/environment-variables/
9+
*/
10+
class Tugboat extends DefaultEnvironment
11+
{
12+
13+
/**
14+
* {@inheritdoc}
15+
*/
16+
public const ENVIRONMENT_NAME = 'TUGBOAT_PREVIEW_NAME';
17+
18+
/**
19+
* {@inheritdoc}
20+
*/
21+
public static function isPreview(): bool
22+
{
23+
return TRUE;
24+
}
25+
26+
}

0 commit comments

Comments
 (0)