<commit_before><?php
namespace Netlogix\JsonApiOrg\Schema;

    /*
     * This file is part of the Netlogix.JsonApiOrg package.
     *
     * This package is Open Source Software. For the full copyright and license
     * information, please view the LICENSE file which was distributed with this
     * source code.
     */
use Netlogix\JsonApiOrg\Domain\Model\LinksAwareModelInterface;
use Netlogix\JsonApiOrg\Schema\Traits\ResourceBasedTrait;

/**
 * @see http://jsonapi.org/format/#document-links
 */
class Links extends AbstractSchemaElement implements \ArrayAccess
{

    use ResourceBasedTrait;

    /**
     * @return array
     */
    public function jsonSerialize()
    {
        $payload = $this->getPayload();
        $links = array();
        if ($payload instanceof LinksAwareModelInterface) {
            $links = $payload->buildLinks($this->getResourceInformation()->getUriBuilder());
        }
        if (empty($links['self'])) {
            $links['self'] = (string)$this->getResourceInformation()->getPublicResourceUri($payload);
        }

        return $links;
    }

    /**
     * @param mixed $offset
     * @return bool
     */
    public function offsetExists($offset)
    {
        return isset($this->jsonSerialize()[$offset]);
    }

    /**
     * @param mixed $offset<commit_msg>TASK: Some links have no self<commit_after><?php
namespace Netlogix\JsonApiOrg\Schema;

    /*
     * This file is part of the Netlogix.JsonApiOrg package.
     *
     * This package is Open Source Software. For the full copyright and license
     * information, please view the LICENSE file which was distributed with this
     * source code.
     */
use Netlogix\JsonApiOrg\Domain\Model\LinksAwareModelInterface;
use Netlogix\JsonApiOrg\Schema\Traits\ResourceBasedTrait;

/**
 * @see http://jsonapi.org/format/#document-links
 */
class Links extends AbstractSchemaElement implements \ArrayAccess
{

    use ResourceBasedTrait;

    /**
     * @return array
     */
    public function jsonSerialize()
    {
        $payload = $this->getPayload();
        $links = array();
        if ($payload instanceof LinksAwareModelInterface) {
            $links = $payload->buildLinks($this->getResourceInformation()->getUriBuilder());
        }
        if (empty($links['self'])) {
            try {
                $links['self'] = (string)$this->getResourceInformation()->getPublicResourceUri($payload);
            } catch (\Exception $e) {}
        }

        return $links;
    }

    /**
     * @param mixed $offset
     * @return bool
     */
    public function offsetExists($offset)
    {
        return isset($this->jsonSerialize()[$offset]);
    }

    /**
     * @param mixed $offset
{'fraction_non_alphanumeric': 0.12189699888847721, 'fraction_numerical': 0.0, 'mean_word_length': 2.609625668449198, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '6636468', 'n_tokens_mistral': 747, 'n_tokens_neox': 729, 'n_words': 176}