Skip to content

Commit e2c2452

Browse files
committed
Added production-migration to environment
1 parent 5d64e44 commit e2c2452

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

Diff for: src/Environment.php

+21-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66

77
class Environment implements StringInterface
88
{
9-
const PRODUCTION = 'production';
10-
const BETA = 'beta';
11-
const STAGE = 'stage';
12-
const DEV = 'dev';
13-
const LOCAL = 'local';
14-
const VAGRANT = 'vagrant';
15-
const DOCKER = 'docker';
9+
const PRODUCTION = 'production';
10+
const PRODUCTION_MIGRATION = 'production-migration';
11+
const BETA = 'beta';
12+
const STAGE = 'stage';
13+
const DEV = 'dev';
14+
const LOCAL = 'local';
15+
const VAGRANT = 'vagrant';
16+
const DOCKER = 'docker';
1617

1718
/**
1819
* @var string
@@ -73,6 +74,7 @@ private function isValid($value)
7374
{
7475
return in_array($value, [
7576
self::PRODUCTION,
77+
self::PRODUCTION_MIGRATION,
7678
self::BETA,
7779
self::STAGE,
7880
self::DEV,
@@ -81,4 +83,16 @@ private function isValid($value)
8183
self::DOCKER,
8284
]);
8385
}
86+
87+
public function isProductionMigration()
88+
{
89+
return $this->value === self::PRODUCTION_MIGRATION;
90+
}
91+
92+
public function isProductionEnvironment()
93+
{
94+
return $this->isProduction()
95+
|| $this->isBeta()
96+
|| $this->isProductionMigration();
97+
}
8498
}

Diff for: tests/unit/src/EnvironmentTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function testInvalidEnvironment()
1616
public function testValidEnvironment()
1717
{
1818
$this->assertEquals('production', new Environment('production'));
19+
$this->assertEquals('production-migration', new Environment('production-migration'));
1920
$this->assertEquals('stage', new Environment('stage'));
2021
$this->assertEquals('dev', new Environment('dev'));
2122
$this->assertEquals('local', new Environment('local'));
@@ -32,5 +33,9 @@ public function testIsMethods()
3233
$this->assertTrue((new Environment('vagrant'))->isLocal());
3334
$this->assertTrue((new Environment('beta'))->isBeta());
3435
$this->assertTrue((new Environment('docker'))->isDocker());
36+
$this->assertTrue((new Environment('production-migration'))->isProductionMigration());
37+
$this->assertTrue((new Environment('production-migration'))->isProductionEnvironment());
38+
$this->assertTrue((new Environment('production'))->isProductionEnvironment());
39+
$this->assertTrue((new Environment('beta'))->isProductionEnvironment());
3540
}
3641
}

0 commit comments

Comments
 (0)