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

/**
 * Class AHDB_Utils_Helper
 *
 * General purpose helper methods
 */
class AHDB_Utils_Helper {

    /**
     * Redirect via header redirect to given url
     *
     * @param string $url
     */
    final public static function redirect( $url ) {
        header("Location: " . $url );
        exit;
    }

    /**
     * Returns true if current OS is Windows, else false
     *
     * @return bool
     */
    final public static function isWindows() {
        return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
    }

    /**
     * Returns an assoc array from a given json file
     *
     * @param string $jsonFile
     * @return array|null
     */
    final public static function getArrayFromJsonFile( $jsonFile ) {
        $ret = NULL;

        if ( file_exists( $jsonFile ) && is_readable( $jsonFile ) ) {
            $ret = json_decode( file_get_contents( $jsonFile ), true );
            if ( !is_array( $ret ) ) {
                $ret = NULL;
            }
        }

        return $ret;
    }
} 