<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/10/16
 * Time: 9:47
 */
class RegisterEncoder
{
    public $mac_addr;
    public $ip_addr;
    public $ip_mask;
    public $ip_gateway;
    public $version;
    public $web_port;
    public $auth_type;
    public $username;
    public $pass;

    public function toJson()
    {
        return json_encode($this);
    }

    public function fromJson($json_obj)
    {
        $this->mac_addr = $json_obj['mac_addr'];
        $this->ip_addr = $json_obj['ip_addr'];
        $this->ip_mask = $json_obj['ip_mask'];
        $this->ip_gateway = $json_obj['ip_gateway'];
        $this->version = $json_obj['version'];
        $this->web_port = $json_obj['web_port'];
        $this->auth_type = $json_obj['auth_type'];
        $this->username = $json_obj['username'];
        $this->pass = $json_obj['pass'];
    }
    
    public static function fromJsonList($json_array)
    {
        $register_encoder_array = array();
        $array_count = count($json_array);
        for($i = 0;$i<$array_count;$i++)
        {
            $register_encoder = new RegisterEncoder();
            $register_encoder->fromJson($json_array[$i]);
            $register_encoder_array[] = $register_encoder;
        }
        return $register_encoder_array;
    }
}