<?php
/********************************************************************************
 * (c)1337 aheadware.com - All rights reserved
 ********************************************************************************/

/**
 * Class AHDB_Utils_Config
 */
class AHDB_Utils_Config {

    private $data = array();

    /**
     * Sets config from json string
     *
     * @param {string} $json JSON string
     */
    public function initFromJson( $json )
    {
        $jsonArr = json_decode( $json, true );

        if ( is_array( $jsonArr ) )
        {
            foreach( $jsonArr as $k => $v )
            {
                $this->set( $k, $v );
            }
        }
    }

    /**
     * Set key/value
     *
     * @param string $key
     * @param mixed $value
     */
    public function set( $key, $value )
    {
        $this->data[ '' . $key ] = $value;
    }

    /**
     * Get key/value
     *
     * @param string $key
     * @return mixed $value
     */
    public function get( $key ) {
        $key = '' . $key;
        if ( isset( $this->data[ $key] ) )
        {
            return $this->data[ $key ];
        }
        else
        {
            return NULL;
        }
    }
} 