File tree Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ ## 0.4.1 - 2021-05-23
6+
7+ ### Added
8+ - Ability to override the environment.
9+
510## 0.4.0 - 2021-05-23
611
712### Added
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ protected function potentiallyThrowRequestException($response)
111111
112112 protected function throwUnlessProduction ($ exception )
113113 {
114- throw_unless (app ()-> environment ('production ' ) , $ exception );
114+ throw_unless (Torchlight:: environment () === 'production ' , $ exception );
115115 }
116116
117117 public function cachePrefix ()
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ class Manager
3131 */
3232 protected $ app ;
3333
34+ /**
35+ * @var null|string
36+ */
37+ protected $ environment ;
38+
3439 /**
3540 * @param Container $app
3641 */
@@ -56,6 +61,22 @@ public function client()
5661 return $ this ->app ->make (Client::class);
5762 }
5863
64+ /**
65+ * @return string
66+ */
67+ public function environment ()
68+ {
69+ return $ this ->environment ?? app ()->environment ();
70+ }
71+
72+ /**
73+ * @param string $environment
74+ */
75+ public function overrideEnvironment ($ environment = null )
76+ {
77+ $ this ->environment = $ environment ;
78+ }
79+
5980 /**
6081 * Get an item out of the config using dot notation.
6182 *
Original file line number Diff line number Diff line change @@ -60,4 +60,18 @@ public function cache_implementation_can_be_set()
6060 $ this ->assertFalse ($ newStore ->has ('original_key ' ));
6161 $ this ->assertTrue ($ newStore ->has ('new_key ' ));
6262 }
63+
64+ /** @test */
65+ public function environment_can_be_set ()
66+ {
67+ $ this ->assertEquals ('testing ' , Torchlight::environment ());
68+
69+ Torchlight::overrideEnvironment ('production ' );
70+
71+ $ this ->assertEquals ('production ' , Torchlight::environment ());
72+
73+ Torchlight::overrideEnvironment (null );
74+
75+ $ this ->assertEquals ('testing ' , Torchlight::environment ());
76+ }
6377}
You can’t perform that action at this time.
0 commit comments