Used select_keys function in place of custom pick function

This commit is contained in:
Alejandro Celaya
2018-11-02 11:08:20 +01:00
parent 521f6f2b18
commit 664dc333ac
2 changed files with 3 additions and 19 deletions

View File

@@ -3,10 +3,6 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Common;
use const ARRAY_FILTER_USE_KEY;
use const JSON_ERROR_NONE;
use function array_filter;
use function Functional\contains;
use function getenv;
use function json_decode as spl_json_decode;
use function json_last_error;
@@ -14,6 +10,7 @@ use function json_last_error_msg;
use function sprintf;
use function strtolower;
use function trim;
use const JSON_ERROR_NONE;
/**
* Gets the value of an environment variable. Supports boolean, empty and null.
@@ -49,19 +46,6 @@ function env($key, $default = null)
return trim($value);
}
/**
* Returns only the keys in keysToPick from provided array
*
* @param array $array
* @param array $keysToPick
*/
function pick(array $array, array $keysToPick): array
{
return array_filter($array, function (string $key) use ($keysToPick) {
return contains($keysToPick, $key);
}, ARRAY_FILTER_USE_KEY);
}
/**
* @throws Exception\InvalidArgumentException
*/