public static function ini($profile = null, $filename = null)
    {
        $filename = $filename ?: (self::getHomeDir() . '/.ebay_sdk/credentials');
        $profile = $profile ?: (getenv(self::ENV_PROFILE) ?: 'default');

        return function () use ($filename, $profile) {
            if (!is_readable($filename)) {
                return new \InvalidArgumentException("Cannot read credentials from $filename");
            }
            $data = parse_ini_file($filename, true);
            if ($data === false) {
                return new \InvalidArgumentException("Invalid credentials file $filename");
            }
            if (!isset($data[$profile])) {
                return new \InvalidArgumentException("'$profile' not found in credentials file");
            }
            if (!isset($data[$profile]['ebay_app_id'])
                || !isset($data[$profile]['ebay_cert_id'])
                || !isset($data[$profile]['ebay_dev_id'])) {
                return new \InvalidArgumentException("No credentials present in INI profile '$profile' ($filename)");
            }

            return new Credentials(
                $data[$profile]['ebay_app_id'],
                $data[$profile]['ebay_cert_id'],
                $data[$profile]['ebay_dev_id']
            );
        };
    }