<?php
namespace Fifa\ConnectId\Sdk\Util;

use InvalidArgumentException;

/**
 * Class File
 * @package Fifa\ConnectId\Sdk\Util
 */
class File
{
    /**
     * Overrides default file_get_contents function by checking that given file exists
     *
     * @param string $filename
     * @param bool $use_include_path
     * @param resource|null $context
     * @param int $offset
     * @return string
     * @throws InvalidArgumentException
     */
    public static function getContents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0): string
    {
        if (!file_exists($filename)) {
            throw new InvalidArgumentException(sprintf('File "%s" does not exist.', $filename));
        }

        return file_get_contents($filename, $use_include_path, $context, $offset);
    }
}