<commit_before><?php
namespace Idane\ProductParser;

class ProductParser
{
    private $filename;
    private $xml;
    private $chainId;
    private $storeId;
    public function parse($filename)
    {
        $this->filename = $filename;
        $this->xml = file_get_contents($this->filename);
        $result = preg_match("/Price(?:Full)?(?<chainId>[0-9]{13})-(?P<storeId>[0-9]{3})/",$this->filename,$match);
        if(!$result)
        {
            throw new \Exception("Invalid XML file format!");
        }

        $this->chainId = $match['chainId'];
        $this->storeId = $match['storeId'];
        $chains = Constants::CHAINS;
        if(!isset($chains[$this->chainId]))
        {
            throw new \Exception("Unrecognized Chain ID");
        }
        $className = Constants::CHAINS[$this->chainId]['class'];
        $chainName = Constants::CHAINS[$this->chainId]['friendly_name'];
        $parser = new $className($this->xml);
        $result = $parser->parse($this->xml);
        $products = [];
        foreach($result[$className::PRODUCT_CONTAINER] as $entry)
        {
            $_product = new Product();
            $_product->storeId = $this->storeId;
            $_product->chainId = $this->chainId;
            $_product->chainName = $chainName;
            $_product->name = $entry['ItemName'];
            $_product->price = floatval($entry['ItemPrice']);
            $products[] = $_product;

        }
        return $products;

    }
}
<commit_msg>Getters/setters for Product object<commit_after><?php
namespace Idane\ProductParser;

class ProductParser
{
    private $filename;
    private $xml;
    private $chainId;
    private $storeId;
    public function parse($filename)
    {
        $this->filename = $filename;
        $this->xml = file_get_contents($this->filename);
        $result = preg_match("/Price(?:Full)?(?<chainId>[0-9]{13})-(?P<storeId>[0-9]{3})/",$this->filename,$match);
        if(!$result)
        {
            throw new \Exception("Invalid XML file format!");
        }

        $this->chainId = $match['chainId'];
        $this->storeId = $match['storeId'];
        $chains = Constants::CHAINS;
        if(!isset($chains[$this->chainId]))
        {
            throw new \Exception("Unrecognized Chain ID");
        }
        $className = Constants::CHAINS[$this->chainId]['class'];
        $chainName = Constants::CHAINS[$this->chainId]['friendly_name'];
        $parser = new $className($this->xml);
        $result = $parser->parse($this->xml);
        $products = [];
        foreach($result[$className::PRODUCT_CONTAINER] as $entry)
        {
            $_product = new Product();
            $_product->setStoreId($this->storeId);
            $_product->setChainId($this->chainId);
            $_product->setChainName($chainName);
            $_product->setName($entry['ItemName']);
            $_product->setPrice(floatval($entry['ItemPrice']));
            $products[] = $_product;

        }
        return $products;

    }
}

{'fraction_non_alphanumeric': 0.17316017316017315, 'fraction_numerical': 0.004662004662004662, 'mean_word_length': 2.4728323699421964, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '1641179', 'n_tokens_mistral': 884, 'n_tokens_neox': 857, 'n_words': 140}