src/Apple/AppStore/Util/Parser.php
public static function parseApplePriceMatrixAll($file, $directory = null)
    {
        $dom = new \DOMDocument();
        $dom->loadHTMLFile($file);

        $xpath = new \DOMXPath($dom);

        // Get all currencies
        $currencies = array();

        /** @var \DOMElement[] $currencyElements */
        $currencyElements = $xpath->query('//table[1]//tr[2]//td[position() > 1]');

        foreach ($currencyElements as $currencyElement) {
            $currency = trim($currencyElement->textContent);

            if ('Euro' == $currency) {
                $currency = 'EUR';
            }

            $currencies[] = $currency;
        }

        if (!count($currencies)) {
            throw new \RuntimeException(sprintf(
                'Not found currencies in ApplePriceMatrix in file "%s".',
                $file
            ));
        }

        $currencies = array_flip($currencies);

        foreach ($currencies as $currency => $null) {
            $currencies[$currency] = static::parseApplePriceMatrix($dom, $currency, $directory);
        }

        return $currencies;
    }
public static function parseApplePriceMatrixAll($file, $directory = null)
    {
        $dom = new \DOMDocument();
        $dom->loadHTMLFile($file);

        $xpath = new \DOMXPath($dom);

        // Get all currencies
        $currencies = array();

        /** @var \DOMElement[] $currencyElements */
        $currencyElements = $xpath->query('//table[1]//tr[2]//td[position() > 1]');

        foreach ($currencyElements as $currencyElement) {
            $currency = trim($currencyElement->textContent);

            if ('Euro' == $currency) {
                $currency = 'EUR';
            }

            $currencies[] = $currency;
        }

        if (!count($currencies)) {
            throw new \RuntimeException(sprintf(
                'Not found currencies in ApplePriceMatrix in file "%s".',
                $file
            ));
        }

        $currencies = array_flip($currencies);

        foreach ($currencies as $currency => $null) {
            $currencies[$currency] = static::parseApplePriceMatrix($dom, $currency, $directory);
        }

        return $currencies;
    }
public static function parseApplePriceMatrixAll ( $ file , $ directory = null ) { $ dom = new \ DOMDocument ( ) ; $ dom -> loadHTMLFile ( $ file ) ; $ xpath = new \ DOMXPath ( $ dom ) ; // Get all currencies $ currencies = array ( ) ; /** @var \DOMElement[] $currencyElements */ $ currencyElements = $ xpath -> query ( '//table[1]//tr[2]//td[position() > 1]' ) ; foreach ( $ currencyElements as $ currencyElement ) { $ currency = trim ( $ currencyElement -> textContent ) ; if ( 'Euro' == $ currency ) { $ currency = 'EUR' ; } $ currencies [ ] = $ currency ; } if ( ! count ( $ currencies ) ) { throw new \ RuntimeException ( sprintf ( 'Not found currencies in ApplePriceMatrix in file "%s".' , $ file ) ) ; } $ currencies = array_flip ( $ currencies ) ; foreach ( $ currencies as $ currency => $ null ) { $ currencies [ $ currency ] = static :: parseApplePriceMatrix ( $ dom , $ currency , $ directory ) ; } return $ currencies ; }
Parse all prices maps from Apple Price Matrix HTML document and save
to PHP files in directory

@param string $file      File path to .htm(l)
@param string $directory Save result to directory

@return array

@throws \InvalidArgumentException
@throws \RuntimeException
Parse all prices maps from Apple Price Matrix HTML document and save to PHP files in directory