src/Service/Cdn.php
protected function formatObject(&$oObj)
    {
        $oObj->id          = (int) $oObj->id;
        $oObj->img_width   = (int) $oObj->img_width;
        $oObj->img_height  = (int) $oObj->img_height;
        $oObj->is_animated = (bool) $oObj->is_animated;
        $oObj->serves      = (int) $oObj->serves;
        $oObj->downloads   = (int) $oObj->downloads;
        $oObj->thumbs      = (int) $oObj->thumbs;
        $oObj->scales      = (int) $oObj->scales;
        $oObj->modified_by = (int) $oObj->modified_by ?: null;

        // --------------------------------------------------------------------------

        $sFileNameDisk  = $oObj->filename;
        $sFileNameHuman = $oObj->filename_display;
        $iFileSize      = (int) $oObj->filesize;

        $oObj->file = (object) [
            'name' => (object) [
                'disk'  => $sFileNameDisk,
                'human' => $sFileNameHuman,
            ],
            'mime' => $oObj->mime,
            'ext'  => strtolower(pathinfo($sFileNameDisk, PATHINFO_EXTENSION)),
            'size' => (object) [
                'bytes'     => $iFileSize,
                'kilobytes' => round($iFileSize / self::BYTE_MULTIPLIER_KB, self::FILE_SIZE_PRECISION),
                'megabytes' => round($iFileSize / self::BYTE_MULTIPLIER_MB, self::FILE_SIZE_PRECISION),
                'gigabytes' => round($iFileSize / self::BYTE_MULTIPLIER_GB, self::FILE_SIZE_PRECISION),
                'human'     => static::formatBytes($iFileSize),
            ],
            'hash' => (object) [
                'md5' => $oObj->md5_hash,
            ],
        ];

        unset($oObj->filename);
        unset($oObj->filename_display);
        unset($oObj->mime);
        unset($oObj->filesize);

        // --------------------------------------------------------------------------

        $oObj->bucket = (object) [
            'id'    => (int) $oObj->bucket_id,
            'label' => $oObj->bucket_label,
            'slug'  => $oObj->bucket_slug,
        ];

        unset($oObj->bucket_id);
        unset($oObj->bucket_label);
        unset($oObj->bucket_slug);

        // --------------------------------------------------------------------------

        //  Quick flag for detecting images
        $oObj->is_img = false;

        switch ($oObj->file->mime) {
            case 'image/jpg':
            case 'image/jpeg':
            case 'image/gif':
            case 'image/png':
                $oObj->is_img = true;
                break;
        }
    }
protected function formatObject(&$oObj)
    {
        $oObj->id          = (int) $oObj->id;
        $oObj->img_width   = (int) $oObj->img_width;
        $oObj->img_height  = (int) $oObj->img_height;
        $oObj->is_animated = (bool) $oObj->is_animated;
        $oObj->serves      = (int) $oObj->serves;
        $oObj->downloads   = (int) $oObj->downloads;
        $oObj->thumbs      = (int) $oObj->thumbs;
        $oObj->scales      = (int) $oObj->scales;
        $oObj->modified_by = (int) $oObj->modified_by ?: null;

        // --------------------------------------------------------------------------

        $sFileNameDisk  = $oObj->filename;
        $sFileNameHuman = $oObj->filename_display;
        $iFileSize      = (int) $oObj->filesize;

        $oObj->file = (object) [
            'name' => (object) [
                'disk'  => $sFileNameDisk,
                'human' => $sFileNameHuman,
            ],
            'mime' => $oObj->mime,
            'ext'  => strtolower(pathinfo($sFileNameDisk, PATHINFO_EXTENSION)),
            'size' => (object) [
                'bytes'     => $iFileSize,
                'kilobytes' => round($iFileSize / self::BYTE_MULTIPLIER_KB, self::FILE_SIZE_PRECISION),
                'megabytes' => round($iFileSize / self::BYTE_MULTIPLIER_MB, self::FILE_SIZE_PRECISION),
                'gigabytes' => round($iFileSize / self::BYTE_MULTIPLIER_GB, self::FILE_SIZE_PRECISION),
                'human'     => static::formatBytes($iFileSize),
            ],
            'hash' => (object) [
                'md5' => $oObj->md5_hash,
            ],
        ];

        unset($oObj->filename);
        unset($oObj->filename_display);
        unset($oObj->mime);
        unset($oObj->filesize);

        // --------------------------------------------------------------------------

        $oObj->bucket = (object) [
            'id'    => (int) $oObj->bucket_id,
            'label' => $oObj->bucket_label,
            'slug'  => $oObj->bucket_slug,
        ];

        unset($oObj->bucket_id);
        unset($oObj->bucket_label);
        unset($oObj->bucket_slug);

        // --------------------------------------------------------------------------

        //  Quick flag for detecting images
        $oObj->is_img = false;

        switch ($oObj->file->mime) {
            case 'image/jpg':
            case 'image/jpeg':
            case 'image/gif':
            case 'image/png':
                $oObj->is_img = true;
                break;
        }
    }
protected function formatObject ( & $ oObj ) { $ oObj -> id = ( int ) $ oObj -> id ; $ oObj -> img_width = ( int ) $ oObj -> img_width ; $ oObj -> img_height = ( int ) $ oObj -> img_height ; $ oObj -> is_animated = ( bool ) $ oObj -> is_animated ; $ oObj -> serves = ( int ) $ oObj -> serves ; $ oObj -> downloads = ( int ) $ oObj -> downloads ; $ oObj -> thumbs = ( int ) $ oObj -> thumbs ; $ oObj -> scales = ( int ) $ oObj -> scales ; $ oObj -> modified_by = ( int ) $ oObj -> modified_by ? : null ; // -------------------------------------------------------------------------- $ sFileNameDisk = $ oObj -> filename ; $ sFileNameHuman = $ oObj -> filename_display ; $ iFileSize = ( int ) $ oObj -> filesize ; $ oObj -> file = ( object ) [ 'name' => ( object ) [ 'disk' => $ sFileNameDisk , 'human' => $ sFileNameHuman , ] , 'mime' => $ oObj -> mime , 'ext' => strtolower ( pathinfo ( $ sFileNameDisk , PATHINFO_EXTENSION ) ) , 'size' => ( object ) [ 'bytes' => $ iFileSize , 'kilobytes' => round ( $ iFileSize / self :: BYTE_MULTIPLIER_KB , self :: FILE_SIZE_PRECISION ) , 'megabytes' => round ( $ iFileSize / self :: BYTE_MULTIPLIER_MB , self :: FILE_SIZE_PRECISION ) , 'gigabytes' => round ( $ iFileSize / self :: BYTE_MULTIPLIER_GB , self :: FILE_SIZE_PRECISION ) , 'human' => static :: formatBytes ( $ iFileSize ) , ] , 'hash' => ( object ) [ 'md5' => $ oObj -> md5_hash , ] , ] ; unset ( $ oObj -> filename ) ; unset ( $ oObj -> filename_display ) ; unset ( $ oObj -> mime ) ; unset ( $ oObj -> filesize ) ; // -------------------------------------------------------------------------- $ oObj -> bucket = ( object ) [ 'id' => ( int ) $ oObj -> bucket_id , 'label' => $ oObj -> bucket_label , 'slug' => $ oObj -> bucket_slug , ] ; unset ( $ oObj -> bucket_id ) ; unset ( $ oObj -> bucket_label ) ; unset ( $ oObj -> bucket_slug ) ; // -------------------------------------------------------------------------- //  Quick flag for detecting images $ oObj -> is_img = false ; switch ( $ oObj -> file -> mime ) { case 'image/jpg' : case 'image/jpeg' : case 'image/gif' : case 'image/png' : $ oObj -> is_img = true ; break ; } }
Formats an object object

@param object $oObj The object to format

@return  void
Formats an object object