src/ApiKeyProvider.php
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];
        };
    }
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];
        };
    }
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 ] ; } ; }
APIKEY provider that read APIKEY in an ini file stored in the current user's home directory.

@param string|null $profile Profile to use. If not specified will use the "default" profile.
@param string|null $filename If provided, uses a custom filename rather than looking in the home directory.

@return callable
APIKEY provider that read APIKEY in an ini file stored in the current user s home directory .