ParagonIE\Halite\Stream\ReadOnlyFile::__construct PHP Method

__construct() public method

ReadOnlyFile constructor
public __construct ( $file, Key $key = null )
$file
$key ParagonIE\Halite\Key
    public function __construct($file, Key $key = null)
    {
        if (is_string($file)) {
            $this->fp = \fopen($file, 'rb');
            $this->closeAfter = true;
            $this->pos = 0;
            $this->stat = \fstat($this->fp);
        } elseif (is_resource($file)) {
            $this->fp = $file;
            $this->pos = \ftell($this->fp);
            $this->stat = \fstat($this->fp);
        } else {
            throw new CryptoException\InvalidType('Argument 1: Expected a filename or resource');
        }
        $this->hashKey = !empty($key) ? $key->getRawKeyMaterial() : '';
        $this->hash = $this->getHash();
    }