private function createTemporaryFile(): string
    {
        $tmpDir = $this->tmpDir;

        $tmpFileName = md5(uniqid((string) mt_rand(), true)).'.p8';

        $tmpFilePath = $tmpDir.'/'.$tmpFileName;

        $errorCode = $errorMessage = null;

        set_error_handler(function ($errCode, $errMessage) use (&$errorCode, &$errorMessage) {
            $errorCode = $errCode;
            $errorMessage = $errMessage;
        });

        if (!file_exists($tmpDir)) {
            mkdir($tmpDir, 0600, true);

            if ($errorCode || $errorMessage) {
                restore_error_handler();
                // Error create directory
                throw new \RuntimeException(sprintf(
                    'Can not create temporary directory "%s". Error: %s [%d].',
                    $tmpDir,
                    $errorMessage ?: 'Undefined',
                    $errorCode ?: '0'
                ));
            }
        }

        touch($tmpFilePath);

        if ($errorCode || $errorMessage) {
            restore_error_handler();

            // Error create file
            throw new \RuntimeException(sprintf(
                'Can not create temporary certificate file "%s". Error: %s [%d].',
                $tmpFilePath,
                $errorMessage ?: 'Undefined',
                $errorCode ?: '0'
            ));
        }

        restore_error_handler();

        return $tmpFilePath;
    }
private function createTemporaryFile(): string
    {
        $tmpDir = $this->tmpDir;

        $tmpFileName = md5(uniqid((string) mt_rand(), true)).'.p8';

        $tmpFilePath = $tmpDir.'/'.$tmpFileName;

        $errorCode = $errorMessage = null;

        set_error_handler(function ($errCode, $errMessage) use (&$errorCode, &$errorMessage) {
            $errorCode = $errCode;
            $errorMessage = $errMessage;
        });

        if (!file_exists($tmpDir)) {
            mkdir($tmpDir, 0600, true);

            if ($errorCode || $errorMessage) {
                restore_error_handler();
                // Error create directory
                throw new \RuntimeException(sprintf(
                    'Can not create temporary directory "%s". Error: %s [%d].',
                    $tmpDir,
                    $errorMessage ?: 'Undefined',
                    $errorCode ?: '0'
                ));
            }
        }

        touch($tmpFilePath);

        if ($errorCode || $errorMessage) {
            restore_error_handler();

            // Error create file
            throw new \RuntimeException(sprintf(
                'Can not create temporary certificate file "%s". Error: %s [%d].',
                $tmpFilePath,
                $errorMessage ?: 'Undefined',
                $errorCode ?: '0'
            ));
        }

        restore_error_handler();

        return $tmpFilePath;
    }
private function createTemporaryFile ( ) : string { $ tmpDir = $ this -> tmpDir ; $ tmpFileName = md5 ( uniqid ( ( string ) mt_rand ( ) , true ) ) . '.p8' ; $ tmpFilePath = $ tmpDir . '/' . $ tmpFileName ; $ errorCode = $ errorMessage = null ; set_error_handler ( function ( $ errCode , $ errMessage ) use ( & $ errorCode , & $ errorMessage ) { $ errorCode = $ errCode ; $ errorMessage = $ errMessage ; } ) ; if ( ! file_exists ( $ tmpDir ) ) { mkdir ( $ tmpDir , 0600 , true ) ; if ( $ errorCode || $ errorMessage ) { restore_error_handler ( ) ; // Error create directory throw new \ RuntimeException ( sprintf ( 'Can not create temporary directory "%s". Error: %s [%d].' , $ tmpDir , $ errorMessage ? : 'Undefined' , $ errorCode ? : '0' ) ) ; } } touch ( $ tmpFilePath ) ; if ( $ errorCode || $ errorMessage ) { restore_error_handler ( ) ; // Error create file throw new \ RuntimeException ( sprintf ( 'Can not create temporary certificate file "%s". Error: %s [%d].' , $ tmpFilePath , $ errorMessage ? : 'Undefined' , $ errorCode ? : '0' ) ) ; } restore_error_handler ( ) ; return $ tmpFilePath ; }
Create a temporary file

@return string Path to temporary file

@throws \RuntimeException
Create a temporary file