<?php namespace Winter\Storm\Database\Attach;

use Winter\Storm\Support\Facades\File as FileHelper;

class BrokenImage
{
    /**
     * Saves a picture of a broken image to a destination path.
     * @param string $savePath Where to save the image
     * @return void
     */
    public static function copyTo($savePath)
    {
        /*
         * Check if save path directory exists
         */
        $directoryPath = dirname($savePath);
        if (!FileHelper::exists($directoryPath)) {
            FileHelper::makeDirectory($directoryPath, 0777, true);
        }

        /*
         * Save broken file image
         */
        FileHelper::put(
            $savePath,
            base64_decode('[encoded data, 7108 characters]')
        );
    }
}
