src/Variables/Specific/Files.php
private function addMimeInfo(): void
    {
        $finfoMimeType = new \finfo(FILEINFO_MIME_TYPE);
        $finfoMimeEncoding = new \finfo(FILEINFO_MIME_ENCODING);

        foreach ($this->variables as $file => $data) {
            foreach ($data as $varName => $varVal) {
                if (\is_array($varVal)) {
                    $this->variables[$file][$varName]['encoding'] = '';

                    if (isset($this->variables[$file][$varName]['error']) &&
                        $this->variables[$file][$varName]['error'] === 0) {

                        $finfoFile = $this->variables[$file][$varName]['tmp_name'];
                        $this->variables[$file][$varName]['type'] = $finfoMimeType->file($finfoFile);
                        $this->variables[$file][$varName]['encoding'] = $finfoMimeEncoding->file($finfoFile);
                    }
                }
                if (!\is_array($varVal)) {
                    $this->variables[$file]['encoding'] = '';

                    if (isset($this->variables[$file]['error']) && $this->variables[$file]['error'] === 0) {
                        $finfoFile = $this->variables[$file]['tmp_name'];
                        $this->variables[$file]['type'] = $finfoMimeType->file($finfoFile);
                        $this->variables[$file]['encoding'] = $finfoMimeEncoding->file($finfoFile);
                    }
                }
            }
        }
    }
private function addMimeInfo(): void
    {
        $finfoMimeType = new \finfo(FILEINFO_MIME_TYPE);
        $finfoMimeEncoding = new \finfo(FILEINFO_MIME_ENCODING);

        foreach ($this->variables as $file => $data) {
            foreach ($data as $varName => $varVal) {
                if (\is_array($varVal)) {
                    $this->variables[$file][$varName]['encoding'] = '';

                    if (isset($this->variables[$file][$varName]['error']) &&
                        $this->variables[$file][$varName]['error'] === 0) {

                        $finfoFile = $this->variables[$file][$varName]['tmp_name'];
                        $this->variables[$file][$varName]['type'] = $finfoMimeType->file($finfoFile);
                        $this->variables[$file][$varName]['encoding'] = $finfoMimeEncoding->file($finfoFile);
                    }
                }
                if (!\is_array($varVal)) {
                    $this->variables[$file]['encoding'] = '';

                    if (isset($this->variables[$file]['error']) && $this->variables[$file]['error'] === 0) {
                        $finfoFile = $this->variables[$file]['tmp_name'];
                        $this->variables[$file]['type'] = $finfoMimeType->file($finfoFile);
                        $this->variables[$file]['encoding'] = $finfoMimeEncoding->file($finfoFile);
                    }
                }
            }
        }
    }
private function addMimeInfo ( ) : void { $ finfoMimeType = new \ finfo ( FILEINFO_MIME_TYPE ) ; $ finfoMimeEncoding = new \ finfo ( FILEINFO_MIME_ENCODING ) ; foreach ( $ this -> variables as $ file => $ data ) { foreach ( $ data as $ varName => $ varVal ) { if ( \ is_array ( $ varVal ) ) { $ this -> variables [ $ file ] [ $ varName ] [ 'encoding' ] = '' ; if ( isset ( $ this -> variables [ $ file ] [ $ varName ] [ 'error' ] ) && $ this -> variables [ $ file ] [ $ varName ] [ 'error' ] === 0 ) { $ finfoFile = $ this -> variables [ $ file ] [ $ varName ] [ 'tmp_name' ] ; $ this -> variables [ $ file ] [ $ varName ] [ 'type' ] = $ finfoMimeType -> file ( $ finfoFile ) ; $ this -> variables [ $ file ] [ $ varName ] [ 'encoding' ] = $ finfoMimeEncoding -> file ( $ finfoFile ) ; } } if ( ! \ is_array ( $ varVal ) ) { $ this -> variables [ $ file ] [ 'encoding' ] = '' ; if ( isset ( $ this -> variables [ $ file ] [ 'error' ] ) && $ this -> variables [ $ file ] [ 'error' ] === 0 ) { $ finfoFile = $ this -> variables [ $ file ] [ 'tmp_name' ] ; $ this -> variables [ $ file ] [ 'type' ] = $ finfoMimeType -> file ( $ finfoFile ) ; $ this -> variables [ $ file ] [ 'encoding' ] = $ finfoMimeEncoding -> file ( $ finfoFile ) ; } } } } }
Adds MIME information to files
Adds MIME information to files