<commit_before><?php

namespace Shoplo;

class ProductVariant extends Resource
{
    public function retrieve($productId, $variantId = 0, $params = array(), $cache = false)
    {
        if ($variantId == 0) {
            if (!$cache || !isset($this->bucket['variant'])) {
                $params                  = $this->prepare_params($params);
                $result                  = empty($params) ? $this->send($this->prefix . "/variants/" . $productId) : $this->send($this->prefix . "/variants/" . $productId ."?". $params);
                $this->bucket['variant'] = $this->prepare_result($result);
            }
            return $this->bucket['variant'];
        } else {
            if (!$cache || !isset($this->bucket['variant'][$variantId])) {
                $result                       = $this->send($this->prefix . "/products/" . $productId . "/variants/" . $variantId);
                $this->bucket['variant'][$variantId] = $this->prepare_result($result);
            }
            return $this->bucket['variant'][$variantId];
        }
    }
}<commit_msg>Added "modify" method to ProductVariant resource<commit_after><?php

namespace Shoplo;

class ProductVariant extends Resource
{
    public function retrieve($productId, $variantId = 0, $params = array(), $cache = false)
    {
        if ($variantId == 0) {
            if (!$cache || !isset($this->bucket['variant'])) {
                $params                  = $this->prepare_params($params);
                $result                  = empty($params) ? $this->send($this->prefix . "/variants/" . $productId) : $this->send($this->prefix . "/variants/" . $productId ."?". $params);
                $this->bucket['variant'] = $this->prepare_result($result);
            }
            return $this->bucket['variant'];
        } else {
            if (!$cache || !isset($this->bucket['variant'][$variantId])) {
                $result                       = $this->send($this->prefix . "/products/" . $productId . "/variants/" . $variantId);
                $this->bucket['variant'][$variantId] = $this->prepare_result($result);
            }
            return $this->bucket['variant'][$variantId];
        }
    }

    public function modify($id, $fields)
    {
        $fields = array('variant' => $fields);
        return $this->send($this->prefix . "/variants/" . $id, 'POST', $fields);
    }
}
{'fraction_non_alphanumeric': 0.18679007151872107, 'fraction_numerical': 0.0016827934371055953, 'mean_word_length': 2.0254452926208653, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5298904', 'n_tokens_mistral': 653, 'n_tokens_neox': 636, 'n_words': 120}