@@ -32,11 +32,17 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | // 'config_name', 'config_value' |
| 34 | 34 | |
| 35 | + /** |
|
| 36 | + * @param string $key |
|
| 37 | + */ |
|
| 35 | 38 | public function has($key) |
| 36 | 39 | { |
| 37 | 40 | return DbConfig::exactKey($key)->exists(); |
| 38 | 41 | } |
| 39 | 42 | |
| 43 | + /** |
|
| 44 | + * @param string $key |
|
| 45 | + */ |
|
| 40 | 46 | public function get($key, $default = null) |
| 41 | 47 | { |
| 42 | 48 | $results = DbConfig::key($key)->get(['config_name', 'config_value']); |
@@ -100,6 +106,9 @@ discard block |
||
| 100 | 106 | return $ret; |
| 101 | 107 | } |
| 102 | 108 | |
| 109 | + /** |
|
| 110 | + * @param \Illuminate\Database\Eloquent\Collection $objs |
|
| 111 | + */ |
|
| 103 | 112 | private function objsToArray($objs) |
| 104 | 113 | { |
| 105 | 114 | $ret = array(); |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | } |
| 46 | 46 | elseif (count($results) == 1) { |
| 47 | 47 | $entry = $results->first(); |
| 48 | - if($entry->config_name != $key) { //FIXME: better test |
|
| 48 | + if ($entry->config_name != $key) { //FIXME: better test |
|
| 49 | 49 | // trim the prefix |
| 50 | 50 | $local_key = substr($entry->config_name, strlen($key) + 1); |
| 51 | 51 | return [$local_key => $entry->config_value]; |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | |
| 50 | 50 | public function scopeKey($query, $key) |
| 51 | 51 | { |
| 52 | - return $query->where('config_name', 'LIKE', $key . '%'); |
|
| 52 | + return $query->where('config_name', 'LIKE', $key.'%'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | public function scopeExactKey($query, $key) |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | private static function recursive_keys(array $array, $prefix = "", array $path = array()) |
| 64 | 64 | { |
| 65 | 65 | if ($prefix != "") { |
| 66 | - $prefix = trim($prefix, '.') . '.'; |
|
| 66 | + $prefix = trim($prefix, '.').'.'; |
|
| 67 | 67 | } |
| 68 | 68 | $result = array(); |
| 69 | 69 | foreach ($array as $key => $val) { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | $result = array_merge($result, self::recursive_keys($val, $prefix, $currentPath)); |
| 73 | 73 | } |
| 74 | 74 | else { |
| 75 | - $result[$prefix . join('.', $currentPath)] = $val; |
|
| 75 | + $result[$prefix.join('.', $currentPath)] = $val; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | return $result; |
@@ -81,18 +81,18 @@ discard block |
||
| 81 | 81 | public function get($key, $default = null) |
| 82 | 82 | { |
| 83 | 83 | // return value from cache or fetch it and return it |
| 84 | - return Cache::remember($key, $this->cache_time, function () use ($key, $default) { |
|
| 84 | + return Cache::remember($key, $this->cache_time, function() use ($key, $default) { |
|
| 85 | 85 | $value = $this->database->get($key, $default); |
| 86 | 86 | |
| 87 | 87 | if (is_array($value)) { |
| 88 | 88 | $value = self::pathToArray($value, $key); |
| 89 | - $config = Config::get('config.' . $key, $default); |
|
| 89 | + $config = Config::get('config.'.$key, $default); |
|
| 90 | 90 | if (!is_null($config)) { |
| 91 | 91 | $value = array_replace_recursive($config, $value); |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | elseif (is_null($value)) { |
| 95 | - return Config::get('config.' . $key); |
|
| 95 | + return Config::get('config.'.$key); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | return $value; |