<?php
//namespace Neteller;

class BillingDetails implements \JsonSerializable{
    private $id;
    private $street;
    private $street2;
    private $city;
    private $state;
    private $zip;
    private $country;

	/*use SetterTrait;
	use GetterTrait;
	use JsonSerializeTrait;*/

    public function __construct($data = null){
        if($data !== null){
            foreach($data as $key => $value){
                $this->$key = $value;
            }
        }
    }

    protected function setStreet($street){
		$this->street = $street;
    }
    
    protected function setStreet2($street2){
        $this->street2 = $street2;
    }
    
    protected function setCity($city){
        $this->city = $city;
    }
    
    protected function setState($state){
        $this->state = $state;
    }
    
    protected function setZip($zip){
        $this->zip = $zip;
    }
    
    protected function setCountry($country){
        $this->country = $country;
    }

    public function __set($name, $value)
    {
        $setter = 'set'.$name;
        if (method_exists($this, $setter)) {
            $this->$setter($value);
        } else {
            $this->$name = $value;
        }
    }

    public function __get($name){
        return $this->$name;
    }

    public function jsonSerialize()
    {
        $vars = array_filter(get_object_vars($this), function($val){ return $val !== null; });
        return $vars;
    }
}
