mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-28 09:51:40 -06:00
Used select_keys function in place of custom pick function
This commit is contained in:
parent
521f6f2b18
commit
664dc333ac
@ -15,7 +15,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Zend\I18n\Translator\TranslatorInterface;
|
||||
use function array_map;
|
||||
use function Shlinkio\Shlink\Common\pick;
|
||||
use function Functional\select_keys;
|
||||
|
||||
class GetVisitsCommand extends Command
|
||||
{
|
||||
@ -92,7 +92,7 @@ class GetVisitsCommand extends Command
|
||||
$rows = array_map(function (Visit $visit) {
|
||||
$rowData = $visit->jsonSerialize();
|
||||
$rowData['country'] = $visit->getVisitLocation()->getCountryName();
|
||||
return pick($rowData, ['referer', 'date', 'userAgent', 'country']);
|
||||
return select_keys($rowData, ['referer', 'date', 'userAgent', 'country']);
|
||||
}, $visits);
|
||||
$io->table([
|
||||
$this->translator->translate('Referer'),
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user