<commit_before><?php
/*
 * This file is part of the reditype package.
 * (c) 2006-2008 digital Wranglers <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * rtShopShipping
 *
 * @package    reditype
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 */
class rtShopShipping
{
	private $_cart_manager;

  /**
   * Constructor
   *
   * @param SteerShopOrder Order object
   */
	public function __construct(rtShopCartManager $cm)
	{
		if($cm->getOrder()->isNew())
		{
			throw new Exception('rtShopOrder object can\'t be new');
		}
    
    $this->_cart_manager = $cm;
	}

  /**
   * Returns the shipping charge.
   *
   * @return float
   */
  public function getShippingCharge()
  {
    $address = $this->getAddress();
    
    $shipping_charge = 0.0;

    if(!$address || !isset($address['country']) || is_null($address['country']) || $address['country'] == '')
    {
      return $shipping_charge;
    }

    $charges_config = sfConfig::get('app_rt_shop_shipping_charges', array());

    if(isset($charges_config[$address['country']]))
    {
      $shipping_charge = $charges_config[$address['country']];
    }
    elseif(isset($charges_config['default']))
    {
      $shipping_charge = $charges_config['default'];
    }

    return $shipping_charge;
  }


  /**
   * Returns an address from the order object.
   *
   * @return array|false
   */
  public function getAddress()
  {
    $address = $this->getCartManager()->getShippingAddress();

    if(count($address) == 0)
    {
      $address = $this->getCartManager()->getBillingAddress();
    }
<commit_msg>Corrected shipping handling.<commit_after><?php
/*
 * This file is part of the reditype package.
 * (c) 2006-2008 digital Wranglers <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * rtShopShipping
 *
 * @package    reditype
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 */
class rtShopShipping
{
	private $_cart_manager;

  /**
   * Constructor
   *
   * @param SteerShopOrder Order object
   */
	public function __construct(rtShopCartManager $cm)
	{
		if($cm->getOrder()->isNew())
		{
			throw new Exception('rtShopOrder object can\'t be new');
		}
    
    $this->_cart_manager = $cm;
	}

  /**
   * Returns the shipping charge.
   *
   * @return float
   */
  public function getShippingCharge()
  {
    $address = $this->getAddress();
    
    $shipping_charge = 0.0;

    if(!$address || !isset($address['country']) || is_null($address['country']) || $address['country'] == '')
    {
      return $shipping_charge;
    }

    $charges_config = sfConfig::get('app_rt_shop_shipping_charges', array());

    if(isset($charges_config[$address['country']]))
    {
      $shipping_charge = $charges_config[$address['country']];
    }
    elseif(isset($charges_config['default']))
    {
      $shipping_charge = $charges_config['default'];
    }

    return $shipping_charge;
  }


  /**
   * Returns an address from the order object.
   *
   * @return array|false
   */
  public function getAddress()
  {
    $address = $this->getCartManager()->getShippingAddress();

    if(!$address)
    {
      $address = $this->getCartManager()->getBillingAddress();
    }

{'fraction_non_alphanumeric': 0.15485407980941035, 'fraction_numerical': 0.006253722453841573, 'mean_word_length': 3.177860696517413, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 35, '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': '4900669', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1073, 'n_words': 227}