<commit_before><?php

namespace Helldar\Helpers\Support;

class Images
{
    /**
     * @var string
     */
    private $filename;

    /**
     * Images constructor.
     *
     * @param $filename
     */
    public function __construct($filename)
    {
        $this->filename = $filename;
    }

    /**
     * Check the existence of the file and return the default value if it is missing.
     *
     * @param null $default
     *
     * @return null|string
     */
    public function imageOrDefault($default = null)
    {
        return file_exists($this->filename) ? $this->filename : $default;
    }
}
<commit_msg>Added check for the existence of files on URL<commit_after><?php

namespace Helldar\Helpers\Support;

class Images
{
    /**
     * @var string
     */
    private $filename;

    /**
     * Images constructor.
     *
     * @param $filename
     */
    public function __construct($filename)
    {
        $this->filename = $filename;
    }

    /**
     * Check the existence of the file and return the default value if it is missing.
     *
     * @param null $default
     *
     * @return null|string
     */
    public function imageOrDefault($default = null)
    {
        if (\Illuminate\Support\Str::contains($this->filename, ['http://', 'https://', 'ftp://'])) {
            return (new Files($this->filename))->urlExists() ? $this->filename : $default;
        }
        
        return file_exists($this->filename) ? $this->filename : $default;
    }
}

{'fraction_non_alphanumeric': 0.13449899125756556, 'fraction_numerical': 0.0, 'mean_word_length': 2.0935550935550937, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, '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': '1035716', 'n_tokens_mistral': 430, 'n_tokens_neox': 430, 'n_words': 110}