<commit_before><?php

use Illuminate\Support\Facades\Request;
use Symfony\Component\HttpFoundation\File\UploadedFile;

if ( ! function_exists('upload_image'))
{
    /**
     * Upload image and get image filename.
     *
     * @param  UploadedFile $file
     * @param  string $path
     * @param  string $event
     * @return string
     */
    function upload_image($file, $path, $event = 'image.uploaded')
    {
        if ( ! is_null($file))
        {
            $filename = sha1(time() . $file->getClientOriginalName()) . '.' . strtolower($file->getClientOriginalExtension());

            $file->move(public_path($path), $filename);

            event($event, [$path . $filename]);
            
            return $filename;
        }

        return null;
    }
}

if ( ! function_exists('set_active'))
{
    /**
     * Set active to specified selector.
     *
     * @param array|string $paths
     * @param string $class
     * @return string
     */
    function set_active($paths, $class = 'active')
    {
        foreach ((array)$paths as $path)
        {
            if (Request::is($path))
            {
                return $class;
            }
        }
    }
}

if (! function_exists('flash'))
{
    /**
     * Flash message.
     *
     * @require "laracasts/flash:~1.3" 
     * 
     * @param  string|null $message
     * @return string|object
     */
    function flash($message = null)
    {
        $flash = app('flash');

        if (is_null($message)) return $flash;

        return $flash->success($message);
    }
}

if (! function_exists('error_for'))
{
    /**
     * Show validation for the specified field.
     * 
     * @param  string $field
     * @param  object $errors
     * @return string
     */
    function error_for($field, $errors, $template = '<div class="text-danger">:message</div>')
    {
        return $errors->first($field, $template);
    }
}
<commit_msg>Squashed 'src/Pingpong/Support/' changes from 7b170c5..a5bea36<commit_after><?php

use Illuminate\Support\Facades\Request;
use Symfony\Component\HttpFoundation\File\UploadedFile;

if ( ! function_exists('upload_image'))
{
    /**
     * Upload image and get image filename.
     *
     * @param  UploadedFile $file
     * @param  string $path
     * @param  string $event
     * @return string
     */
    function upload_image($file, $path, $event = 'image.uploaded')
    {
        if ( ! is_null($file))
        {
            $filename = sha1(time() . $file->getClientOriginalName()) . '.' . strtolower($file->getClientOriginalExtension());

            $file->move(public_path($path), $filename);

            event($event, [$path . $filename]);
            
            return $filename;
        }

        return null;
    }
}

if ( ! function_exists('set_active'))
{
    /**
     * Set active to specified selector.
     *
     * @param array|string $paths
     * @param string $class
     * @return string
     */
    function set_active($paths, $class = 'active')
    {
        foreach ((array)$paths as $path)
        {
            if (Request::is($path))
            {
                return $class;
            }
        }
    }
}

if (! function_exists('flash'))
{
    /**
     * Flash message.
     *
     * @require "laracasts/flash:~1.3" 
     * 
     * @param  string|null $message
     * @return string|object
     */
    function flash($message = null)
    {
        $flash = app('flash');

        if (is_null($message)) return $flash;

        return $flash->success($message);
    }
}

if (! function_exists('error_for'))
{
    /**
     * Show validation for the specified field.
     * 
     * @param  string $field
     * @param  object $errors
     * @return string
     */
    function error_for($field, $errors, $template = '<div class="text-danger">:message</div>')
    {
        return $errors->first($field, $template);
    }
}

if (! function_exists('gravatar')) {
    /**
    * Gravatar URL from Email address
    *
    * @param string $email Email address
    * @param string $size Size in pixels
    * @param string $default Default image [ 404 | mm | identicon | monsterid | wavatar ]
    * @param string $rating Max rating [ g | pg | r | x ]
    *
    * @return string
    */
    function gravatar($email, $size = 60, $default = 'mm', $rating = 'g')
    {
        return 'http://www.gravatar.com/avatar/' . md5(strtolower(trim($email))) . "?s={$size}&d={$default}&r={$rating}";
    }
}
{'fraction_non_alphanumeric': 0.1510840108401084, 'fraction_numerical': 0.004516711833785004, 'mean_word_length': 2.0842618384401113, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1939612', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1355, 'n_words': 291}