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

Commit cd07696

Browse files
author
Robert Kummer
committed
added missing env file
1 parent bc367cf commit cd07696

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/helpers.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Adding support for the missing env() method on laravel 4.
4+
*
5+
* taken from Illuminate/Foundation/helpers.php from laravel 5.
6+
*/
7+
8+
9+
if (! function_exists('env')) {
10+
/**
11+
* Gets the value of an environment variable. Supports boolean, empty and null.
12+
*
13+
* @param string $key
14+
* @param mixed $default
15+
* @return mixed
16+
*/
17+
function env($key, $default = null)
18+
{
19+
$value = getenv($key);
20+
21+
if ($value === false) {
22+
return value($default);
23+
}
24+
25+
switch (strtolower($value)) {
26+
case 'true':
27+
case '(true)':
28+
return true;
29+
30+
case 'false':
31+
case '(false)':
32+
return false;
33+
34+
case 'empty':
35+
case '(empty)':
36+
return '';
37+
38+
case 'null':
39+
case '(null)':
40+
return;
41+
}
42+
43+
if (Str::startsWith($value, '"') && Str::endsWith($value, '"')) {
44+
return substr($value, 1, -1);
45+
}
46+
47+
return $value;
48+
}
49+
}

0 commit comments

Comments
 (0)