<commit_before><?php

namespace BoomCMS\Chunk\Linkset;

use BoomCMS\Link\Link as LinkObject;
use BoomCMS\Support\Facades\Chunk;

class Link
{
    /**
     * @var array
     */
    protected $attrs;

    /**
     * @var Link
     */
    protected $link;

    public function __construct($attrs)
    {
        $this->attrs = $attrs;

        if (isset($attrs['link'])) {
            $this->link = $attrs['link'];
        }
    }

    public function getAssetId()
    {
        return $this->attrs['asset_id'];
    }

    public function getId()
    {
        return $this->attrs['id'];
    }

    /**
     * @return Link
     */
    public function getLink()
    {
        if ($this->link === null) {
            $this->link = LinkObject::factory($this->getUrl());
        }

        return $this->link;
    }

    public function getTarget()
    {
        return $this->getLink();
    }

    public function getTargetPageId()
    {
        return $this->attrs['target_page_id'];
    }

    /**
     * Get the text for the link.
     *
     * If text has been given then that is used.
     *
     * Otherwise, if the link is internal, then the standfirst of the linked page is returned.
     *
     * @return string
     */
    public function getText()
    {
        if (isset($this->attrs['text'])) {
            return $this->attrs['text'];
        }

        if ($this->getLink()->isInternal()) {
            $page = $this->getLink()->getPage();

            return $this->attrs['text'] = $page ? Chunk::get('text', 'standfirst', $page)->text() : '';
        }

        return $this->attrs['text'] = '';
    }

    /**
     * Returns the contents of the text attribute.
     *
     * @return string
     */
    public function getTextAttribute()
    {
        return isset($this->attrs['text']) ? $this->attrs['text'] : '';
    }

    public function getTitle()
    {
        return (isset($this->attrs['title']) && $this->attrs['title']) ?
            $this->attrs['title'] :
            $this->getLink()->getTitle();
    }

    public function getUrl()
    {
        return $this->attrs['url'];
    }

    public function isInternal()
    {
        return $this->getLink()->isInternal();
    }

    public function isExternal()
    {
        return !$this->isInternal();
    }
}<commit_msg>Fixed missing comments<commit_after><?php

namespace BoomCMS\Chunk\Linkset;

use BoomCMS\Link\Link as LinkObject;
use BoomCMS\Support\Facades\Chunk;

class Link
{
    /**
     * @var array
     */
    protected $attrs;

    /**
     * @var Link
     */
    protected $link;

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

        if (isset($attrs['link'])) {
            $this->link = $attrs['link'];
        }
    }

    /**
     * Returns the ID of the link's associated asset.
     *
     * @return int
     */
    public function getAssetId()
    {
        return $this->attrs['asset_id'];
    }

    /**
     * Returns the database ID of the link.
     *
     * @return int
     */
    public function getId()
    {
        return $this->attrs['id'];
    }

    /**
     * @return Link
     */
    public function getLink()
    {
        if ($this->link === null) {
            $this->link = LinkObject::factory($this->getUrl());
        }

        return $this->link;
    }

    /**
     * Alias for getLink().
     *
     * @return Link
     */
    public function getTarget()
    {
        return $this->getLink();
    }

    public function getTargetPageId()
    {
        return $this->attrs['target_page_id'];
    }

    /**
     * Get the text for the link.
     *
     * If text has been given then that is used.
     *
     * Otherwise, if the link is internal, then the standfirst of the linked page is returned.
     *
     * @return string
     */
    public function getText()
    {
        if (isset($this->attrs['text'])) {
            return $this->attrs['text'];
        }

        if ($this->getLink()->isInternal()) {
            $page = $this->getLink()->getPage();

            return $this->attrs['text'] = $page ? Chunk::get('text', 'standfirst', $page)->text() : '';
        }

        return $this->attrs['text'] = '';
    }

    /**
     * Returns the contents of the text attribute.
     *
     * @return string
     */
    public function getTextAttribute()
    {
        return isset($this->attrs['text']) ? $this->attrs['text'] : '';
    }

    /**
     * Returns the link title.
     *
     * @return string
     */
    public function getTitle()
    {
        return (isset($this->attrs['title']) && $this->attrs['title']) ?
            $this->attrs['title'] :
            $this->getLink()->getTitle();
    }

    /**
     * Returns the link URL.
     *
     * @return string
     */
    public function getUrl()
    {
        return $this->attrs['url'];
    }

    /**
     * Returns true if the link is an  internal link.
     *
     * @return bool
     */
    public function isInternal()
    {
        return $this->getLink()->isInternal();
    }

    /**
     * Returns true if the link is an external link.
     *
     * @return bool
     */
    public function isExternal()
    {
        return !$this->isInternal();
    }
}
{'fraction_non_alphanumeric': 0.15870893812070283, 'fraction_numerical': 0.0, 'mean_word_length': 1.7447589098532494, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, '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': '4313429', 'n_tokens_mistral': 1587, 'n_tokens_neox': 1546, 'n_words': 361}