<?php // vim:set et ts=4 sw=4 sts=4:
# Copyright (C) 2003-2014 hipplay Inc.
#
# This is UNPUBLISHED PROPRIETARY SOURCE CODE OF hipplay Inc.
# The copyright notice above does not evidence any actual or intended
# publication of such source code. The contents of this file may not
# be disclosed to third parties, copied or duplicated in any form, in
# whole or in part, without the prior written permission of
# hipplay Inc.
#

namespace HipPlayConnect\Configuration;

class AxOERelease {

    const CONFIG_FILE   = '/etc/oe-release';
    const CONFIG_FORMAT = AxConfigurationFile::SPACE_SEPARATED;

    const CONFIG_KEY_VERSION         = 'Version';
    const CONFIG_KEY_DIST_NAME       = 'DistName';
    const CONFIG_KEY_VERSION_NAME    = 'VersionName';
    const CONFIG_KEY_CENTRAL_SERVER  = 'CentralServer';
    const CONFIG_KEY_THIRD_PARTY     = 'ThirdParty';
    const CONFIG_KEY_SERIAL          = 'Serial';
    const CONFIG_KEY_SUBDOMAIN       = 'Subdomain';
    const CONFIG_KEY_FRIENDLY_NAME   = 'FriendlyName';
    const CONFIG_KEY_BUILD_PLATFORM  = 'BuildPlatform';
    const CONFIG_KEY_BUILD_TARGET    = 'BuildTarget';
    const CONFIG_KEY_BUILD_TIMESTAMP = 'BuildTimestamp';

    protected static $INSTANCE = NULL;

    /**
     * Retrieve the value of the specified key from the Branding configuration.
     *
     * @param string $key     The configuration value to retrieve.
     * @param mixed  $default Value to return if the configured value
     *                        does not exist or is empty.
     *
     * @return string The configured value, or the supplied default.
     */
    public static function get ($key, $default = NULL) {
        return self::getInstance()->getKey($key, $default);
    }

    private static function getInstance () {
        if (self::$INSTANCE === NULL)
            self::$INSTANCE = new AxConfigurationFile(
                    self::CONFIG_FILE,
                    self::CONFIG_FORMAT
            );

        return self::$INSTANCE;
    }

} 