mirror of
https://github.com/predis/predis.git
synced 2026-08-22 05:30:57 +00:00
37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Predis\Commands;
|
|
|
|
class ZSetUnionStore extends Command {
|
|
public function getId() { return 'ZUNIONSTORE'; }
|
|
public function filterArguments(Array $arguments) {
|
|
$options = array();
|
|
$argc = count($arguments);
|
|
if ($argc > 2 && is_array($arguments[$argc - 1])) {
|
|
$options = $this->prepareOptions(array_pop($arguments));
|
|
}
|
|
if (is_array($arguments[1])) {
|
|
$arguments = array_merge(
|
|
array($arguments[0], count($arguments[1])),
|
|
$arguments[1]
|
|
);
|
|
}
|
|
return array_merge($arguments, $options);
|
|
}
|
|
private function prepareOptions($options) {
|
|
$opts = array_change_key_case($options, CASE_UPPER);
|
|
$finalizedOpts = array();
|
|
if (isset($opts['WEIGHTS']) && is_array($opts['WEIGHTS'])) {
|
|
$finalizedOpts[] = 'WEIGHTS';
|
|
foreach ($opts['WEIGHTS'] as $weight) {
|
|
$finalizedOpts[] = $weight;
|
|
}
|
|
}
|
|
if (isset($opts['AGGREGATE'])) {
|
|
$finalizedOpts[] = 'AGGREGATE';
|
|
$finalizedOpts[] = $opts['AGGREGATE'];
|
|
}
|
|
return $finalizedOpts;
|
|
}
|
|
}
|