/** * Get an environment variable or return the default if it is not defined. * * @param string $key * @param null|mixed|callable $default * * @return bool|mixed|null|string */ public static function get($key, $default = null) { $value = static::getRaw($key, $default); if (is_string($value)) { // Convert some common values into their scalar types. switch (strtolower($value)) { case 'true': return true; case 'false': return false; case 'null': return null; } // Strip "" if the string is wrapped in them. if (Str::beginsWith($value, '"') && Str::endsWith($value, '"')) { return substr($value, 1, -1); } } return $value; }
public function testEndsWith() { $this->assertEqualsMatrix([[true, Str::endsWith('hello world', 'world')], [true, Str::endsWith('hello world', '')], [false, Str::endsWith('hello world', 'omg')], [false, Str::endsWith('hello world', 'hello world ')]]); }