示例#1
0
 /**
  * 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;
 }
 /**
  * Get all the API ResourceFactories for this application.
  *
  * @return ResourceFactory[]
  */
 public function getApiResources()
 {
     return Std::filter(function (ResourceFactory $resource) {
         foreach ($this->getApiPrefixes() as $prefix) {
             if (Str::beginsWith($resource->getPrefix(), $prefix)) {
                 return true;
             }
         }
         return false;
     }, $this->getResources());
 }
示例#3
0
 public function testBeginsWith()
 {
     $this->assertEqualsMatrix([[true, Str::beginsWith('hello world', 'hello')], [true, Str::beginsWith('hello world', '')], [false, Str::beginsWith('hello world', 'omg')], [false, Str::beginsWith('hello world', 'hello world ')]]);
 }