private function validateInsert($at, $selector, $items)
    {
        $insertLocations = ['before', 'after', 'replace'];
        $signature = 'insert(at, selector, items)';

        $index = array_search($at, $insertLocations);
        if ($index === false) {
            $valid = implode(', ', array_map(function ($loc) {
                return '"' . $loc . '"';
            }, $insertLocations));
            throw new InvalidArgumentException($signature . ' takes an "at"-argument which is one of: ' . $valid);
        }

        if (!is_string($selector)) {
            throw new InvalidArgumentException($signature . ' takes a "selector"-argument which must be a string');
        }

        if (!is_array($items)) {
            throw new InvalidArgumentException($signature . ' takes an "items"-argument which must be an array');
        }
    }