private static function determinePlaceholderPositions($query, $placeholder)
    {
        // Placeholder positions.
        $placeholderPositions = array();

        // TRUE if we are in an escaped section else FALSE.
        $escaped = false;

        // The placeholder length.
        $placeholderLength = strlen($placeholder);

        // The placeholder position limit before which it can be found.
        $placeolderPositionLimit = strlen($query) - $placeholderLength + 1;

        // Iterache each query char to find the placeholder.
        for ($placeholderPosition = 0; $placeholderPosition < $placeolderPositionLimit; $placeholderPosition++) {

            // Switch the escaped flag if the current query char is a escape delimiter.
            if (in_array($query[$placeholderPosition], array('\'', '"'))) {
                $escaped = !$escaped;
            }

            // Collect the placeholder position if we are not in an escaped section and there is the placeholder at the
            // current position.
            if (!$escaped && (substr($query, $placeholderPosition, $placeholderLength) === $placeholder)) {
                $placeholderPositions[] = $placeholderPosition;
            }
        }

        // Check if the placeholder has been found.
        if (empty($placeholderPositions)) {
            throw QueryRewriterException::namedPlaceholderDoesNotExist($placeholder, $query);
        }

        return $placeholderPositions;
    }