public static function ini($profile = null, $filename = null)
    {
        $filename = $filename ?: (self::getHomeDir() . self::INI_DEFAULT_FILE);
        $profile = $profile ?: self::INI_PROFILE;

        return function () use ($profile, $filename) {
            if (!is_readable($filename)) {
                throw new RuntimeException("Cannot read credentials from $filename");
            }

            $data = @parse_ini_file($filename, true);

            if ($data === false) {
                throw new UnexpectedValueException("Invalid credentials file: $filename");
            }

            if (!isset($data[$profile])) {
                throw new UnexpectedValueException("'$profile' not found in credentials file");
            }

            if (!isset($data[$profile][self::INI_APIKEY])) {
                throw new UnexpectedValueException('No APIKEY present in INI profile ' . "'$profile' ($filename)");
            }

            return $data[$profile][self::INI_APIKEY];
        };
    }