public function extract($value)
    {
        if (!$value instanceof FileInterface) {
            return null;
        }
        
        // Store binary data in temporary file.
        $tmp = tempnam(sys_get_temp_dir(), 'yk-copy.');
        $out = fopen($tmp, 'w');
        $in  = $value->getResource();
        
        // ensures garbage removal
        register_shutdown_function(
            function ($filename) {
                @unlink($filename);
            },
            $tmp
        );
        
        while (!feof($in)) {
            fputs($out, fgets($in, 1024));
        }
        fclose($in);
        fclose($out);

        $return = ["file" => $tmp];

        foreach (['user', 'name', 'type'] as $key) {
            $v = $value->{"get$key"}();
            if ($v) {
                $return[$key]=$v;
            }
        }

        return $return;
    }
public function extract($value)
    {
        if (!$value instanceof FileInterface) {
            return null;
        }
        
        // Store binary data in temporary file.
        $tmp = tempnam(sys_get_temp_dir(), 'yk-copy.');
        $out = fopen($tmp, 'w');
        $in  = $value->getResource();
        
        // ensures garbage removal
        register_shutdown_function(
            function ($filename) {
                @unlink($filename);
            },
            $tmp
        );
        
        while (!feof($in)) {
            fputs($out, fgets($in, 1024));
        }
        fclose($in);
        fclose($out);

        $return = ["file" => $tmp];

        foreach (['user', 'name', 'type'] as $key) {
            $v = $value->{"get$key"}();
            if ($v) {
                $return[$key]=$v;
            }
        }

        return $return;
    }
public function extract ( $ value ) { if ( ! $ value instanceof FileInterface ) { return null ; } // Store binary data in temporary file. $ tmp = tempnam ( sys_get_temp_dir ( ) , 'yk-copy.' ) ; $ out = fopen ( $ tmp , 'w' ) ; $ in = $ value -> getResource ( ) ; // ensures garbage removal register_shutdown_function ( function ( $ filename ) { @ unlink ( $ filename ) ; } , $ tmp ) ; while ( ! feof ( $ in ) ) { fputs ( $ out , fgets ( $ in , 1024 ) ) ; } fclose ( $ in ) ; fclose ( $ out ) ; $ return = [ "file" => $ tmp ] ; foreach ( [ 'user' , 'name' , 'type' ] as $ key ) { $ v = $ value -> { "get$key" } ( ) ; if ( $ v ) { $ return [ $ key ] = $ v ; } } return $ return ; }
Extracts the source file entity.

Stores the binary content in a temporarily file.
Returns the meta data along the name of the temporarily file as an array.

If <b>$value</b> is not of the type FileInterface, nothing will be done,
and <i>NULL</i> is returned.

@param FileInterface|null $value
@return array|null
@see \Zend\Hydrator\Strategy\StrategyInterface::extract()
Extracts the source file entity .