<commit_before><?php
namespace TypiCMS\Presenters;

use Carbon\Carbon;
use Croppa;
use Illuminate\Database\Eloquent\Model;
use URL;

abstract class Presenter
{

    /**
     * @var mixed
     */
    protected $entity;

    /**
     * @param $entity
     */
    public function __construct($entity)
    {
        $this->entity = $entity;
    }

    /**
     * Allow for property-style retrieval
     *
     * @param $property
     * @return mixed
     */
    public function __get($property)
    {
        if (method_exists($this, $property)) {
            return $this->{$property}();
        }

        return $this->entity->{$property};
    }

    /**
     * Return resource's date or curent date if empty
     *
     * @param  string $column
     * @return Carbon
     */
    public function dateOrNow($column = 'date')
    {
        $date = $this->entity->$column ? : Carbon::now() ;
        return $date->format('Y-m-d');
    }

    /**
     * Return resource's time or curent time if empty
     *
     * @param  string $column
     * @return Carbon
     */
    public function timeOrNow($column = 'date')
    {
        $date = $this->entity->$column ? : Carbon::now() ;
        return $date->format('H:i');
    }

    /**<commit_msg>presenter link<commit_after><?php
namespace TypiCMS\Presenters;

use Carbon\Carbon;
use Croppa;
use Illuminate\Database\Eloquent\Model;
use URL;

abstract class Presenter
{

    /**
     * @var mixed
     */
    protected $entity;

    /**
     * @param $entity
     */
    public function __construct($entity)
    {
        $this->entity = $entity;
    }

    /**
     * Allow for property-style retrieval
     *
     * @param $property
     * @return mixed
     */
    public function __get($property)
    {
        if (method_exists($this, $property)) {
            return $this->{$property}();
        }

        return $this->entity->{$property};
    }

    /**
     * Return resource's date or curent date if empty
     *
     * @param  string $column
     * @return Carbon
     */
    public function dateOrNow($column = 'date')
    {
        $date = $this->entity->$column ? : Carbon::now() ;
        return $date->format('Y-m-d');
    }

    /**
     * Return resource's time or curent time if empty
     *
     * @param  string $column
     * @return Carbon
     */
    public function timeOrNow($column = 'date')
    {
        $date = $this->entity->$column ? : Carbon::now() ;
        return $date->format('H:i');
    }

    /**
     * Get url without http://
     * 
     * @param  string $column
     * @return string
     */
    public function urlWithoutScheme($column = 'website')
    {
        return str_replace('http://', '', $this->entity->$column);
    }

    /**
     * Generate an external link
     * 
     * @param  string $column
     * @return string
     */
    public function link($column = 'website')
    {
        return '<a href="' . $this->entity->$column . '" target="_blank">' . $this->urlWithoutScheme($column) . '</a>';
    }

    /**
{'fraction_non_alphanumeric': 0.15305444887118194, 'fraction_numerical': 0.0, 'mean_word_length': 1.9423828125, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 30, 'https://': 0, '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': '4012353', 'n_tokens_mistral': 948, 'n_tokens_neox': 912, 'n_words': 211}