PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /home/trave494/seoshop.live/wp-content/plugins/cart66/pro/models/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : //home/trave494/seoshop.live/wp-content/plugins/cart66/pro/models/SpreedlyXmlObject.php

<?php

abstract class SpreedlyXmlObject {
  /**
   * @var SimpleXMLElement
   * The data loaded for the Spreedly subscriber
   */
  protected $_data;
  
  public function getData() {
    return $this->_data;
  }
  
  public function setData(SimpleXMLElement $data) {
    $this->_data = $data;
  }
  
  public function __get($key) {
    $value = false;
    $key = SpreedlyCommon::camelToDash($key);
    $funcName = "_get" . ucwords($key);
    if(method_exists($this, $funcName)) {
      $value = $this->{$funcName}();
    }
    elseif(get_class($this->_data) == 'SimpleXMLElement') {
      $value = $this->_data->$key;
    }
    return $value;
  }
  
  /**
   * Convert the SimpleXmlElement to an assoc array.
   * If the prune parameter is true, the array will not include keys for empty values
   * 
   * @param boolean $prune
   * @return array
   */
  public function toArray($prune=false, $omit=null) {
    $data = array();
    foreach($this->_data as $key => $value) {
      $value = (string)$value;
      if($prune) {
        if(!empty($value)) {
          $data[$key] = $value;
        }
      }
      else {
        $data[$key] = $value;
      }
    }
    
    if(isset($omit) && is_array($omit)) {
      foreach($omit as $key) {
        unset($data[$key]);
      }
    }
    
    return $data;
  }
  
  /**
   * Populate the protected $_data SimpleXmlElement with the passed in array
   * Warning: no validation is done so you can end up with some crazy SimpleXmlElement objects
   * if you aren't careful passing in valid arrays.
   * 
   * The array keys may be camelCaseWords or dash-type-words. If they are camelCaseWords, they 
   * will be converted to dash-type-words for the SimpleXmlElement.
   * 
   * @param array $data
   * @param string $wrapper
   * @return void
   */
  public function hydrate(array $data, $wrapper) {
    $wrapper = SpreedlyCommon::camelToDash($wrapper);
    $xml = '<' . $wrapper . '/>';
    $xml = new SimpleXmlElement($xml);
    foreach($data as $key => $value) {
      $key = SpreedlyCommon::camelToDash($key);
      $xml->addChild($key, $value);
    }
    $this->setData($xml);
  }
  
}