DominionEnterprises\Mongo\Queue::verifySort PHP Method

verifySort() private static method

Helper method to validate keys and values for the given sort array
private static verifySort ( array $sort, string $label, &$completeFields ) : void
$sort array The proposed sort for a mongo index.
$label string The name of the variable given to the public ensureXIndex method.
return void
    private static function verifySort(array $sort, $label, &$completeFields)
    {
        foreach ($sort as $key => $value) {
            if (!is_string($key)) {
                throw new \InvalidArgumentException("key in \${$label} was not a string");
            }
            if ($value !== 1 && $value !== -1) {
                throw new \InvalidArgumentException("value of \${$label} is not 1 or -1 for ascending and descending");
            }
            $completeFields["payload.{$key}"] = $value;
        }
    }