public static function createFromEnv($section = 'default')
    {
        $section = strtoupper($section);

        $prefix = isset($_ENV['AKAMAI_' . $section . '_HOST']) ? 'AKAMAI_' . $section . '_' : 'AKAMAI_';

        $vars = array('HOST', 'CLIENT_TOKEN', 'CLIENT_SECRET', 'ACCESS_TOKEN');

        foreach ($vars as $var) {
            if (!isset($_ENV[$prefix . $var])) {
                throw new ConfigException(sprintf(
                    'Environment variable%s %sAKAMAI_%s_%s do%s not exist',
                    $section === 'DEFAULT' ? 's' : '',
                    $section === 'DEFAULT' ? 'AKAMAI_' . $var . ' or ' : '',
                    $section,
                    $var,
                    $section === 'DEFAULT' ? '' : 'es'
                ));
            }
        }

        $auth = new static();
        $auth->setAuth(
            $_ENV[$prefix . 'CLIENT_TOKEN'],
            $_ENV[$prefix . 'CLIENT_SECRET'],
            $_ENV[$prefix . 'ACCESS_TOKEN']
        );

        $auth->setHost($_ENV[$prefix . 'HOST']);

        if (isset($_ENV[$prefix . 'MAX_SIZE'])) {
            $auth->setMaxBodySize($_ENV[$prefix . 'MAX_SIZE']);
        }

        return $auth;
    }
public static function createFromEnv($section = 'default')
    {
        $section = strtoupper($section);

        $prefix = isset($_ENV['AKAMAI_' . $section . '_HOST']) ? 'AKAMAI_' . $section . '_' : 'AKAMAI_';

        $vars = array('HOST', 'CLIENT_TOKEN', 'CLIENT_SECRET', 'ACCESS_TOKEN');

        foreach ($vars as $var) {
            if (!isset($_ENV[$prefix . $var])) {
                throw new ConfigException(sprintf(
                    'Environment variable%s %sAKAMAI_%s_%s do%s not exist',
                    $section === 'DEFAULT' ? 's' : '',
                    $section === 'DEFAULT' ? 'AKAMAI_' . $var . ' or ' : '',
                    $section,
                    $var,
                    $section === 'DEFAULT' ? '' : 'es'
                ));
            }
        }

        $auth = new static();
        $auth->setAuth(
            $_ENV[$prefix . 'CLIENT_TOKEN'],
            $_ENV[$prefix . 'CLIENT_SECRET'],
            $_ENV[$prefix . 'ACCESS_TOKEN']
        );

        $auth->setHost($_ENV[$prefix . 'HOST']);

        if (isset($_ENV[$prefix . 'MAX_SIZE'])) {
            $auth->setMaxBodySize($_ENV[$prefix . 'MAX_SIZE']);
        }

        return $auth;
    }
public static function createFromEnv ( $ section = 'default' ) { $ section = strtoupper ( $ section ) ; $ prefix = isset ( $ _ENV [ 'AKAMAI_' . $ section . '_HOST' ] ) ? 'AKAMAI_' . $ section . '_' : 'AKAMAI_' ; $ vars = array ( 'HOST' , 'CLIENT_TOKEN' , 'CLIENT_SECRET' , 'ACCESS_TOKEN' ) ; foreach ( $ vars as $ var ) { if ( ! isset ( $ _ENV [ $ prefix . $ var ] ) ) { throw new ConfigException ( sprintf ( 'Environment variable%s %sAKAMAI_%s_%s do%s not exist' , $ section === 'DEFAULT' ? 's' : '' , $ section === 'DEFAULT' ? 'AKAMAI_' . $ var . ' or ' : '' , $ section , $ var , $ section === 'DEFAULT' ? '' : 'es' ) ) ; } } $ auth = new static ( ) ; $ auth -> setAuth ( $ _ENV [ $ prefix . 'CLIENT_TOKEN' ] , $ _ENV [ $ prefix . 'CLIENT_SECRET' ] , $ _ENV [ $ prefix . 'ACCESS_TOKEN' ] ) ; $ auth -> setHost ( $ _ENV [ $ prefix . 'HOST' ] ) ; if ( isset ( $ _ENV [ $ prefix . 'MAX_SIZE' ] ) ) { $ auth -> setMaxBodySize ( $ _ENV [ $ prefix . 'MAX_SIZE' ] ) ; } return $ auth ; }
Create instance using environment variables

@param string $section
@return Authentication
@throws \Akamai\Open\EdgeGrid\Authentication\Exception\ConfigException
Create instance using environment variables