<commit_before><?php

namespace TyHand\JsonApiToolsBundle\ApiResource;

class Attribute
{
    /**
     * Name of the attribute
     * @var string
     */
    private $name;

    /**
     * Name of the attribute in json
     * @var string
     */
    private $jsonName;

    /**
     * Property linked to the attribute
     * @var string
     */
    private $property;

    /**
     * Entity whose property it is
     * @var string
     */
    private $entity;

    /**
     * Sortable
     * @var boolean
     */
    private $sortable;

    /**
     * Read Only
     * @var boolean
     */
    private $readOnly;

    /**
     * Formatter
     * @var Formatter
     */
    private $formatter;

    /**
     * Input Only
     * @var boolean
     */
    private $inputOnly;

    /**
     * Constructor
     * @param string $name Name of the attribute
     */
    public function __construct($name)
    {
        $this->name = $name;
    }

    /**
     * Add the attribute value to the json outpu
     * @param  mixed $entity Entity or entity collection
     * @param  array $json   Hash for json output
     * @return array         Altered json hash
     */
    public function addToJson($entity, array $json)
    {
        if (is_array($entity)) {
            if (array_key_exists($this->getEntity(), $entity)) {
                $json['attributes'][$this->getJsonName()] = $this->getFormatter()->toJson($entity[$this->getEntity()]->{'get' . $this->property}());
            }
        } else {
            $json['attributes'][$this->getJsonName()] = $this->getFormatter()->toJson($entity->{'get' . $this->property}());
        }

        return $json;
    }

    /**
     * Add the attribute back to the entity
     * @param  mixed $entity Entity or entity collection<commit_msg>Missing ucfrist<commit_after><?php

namespace TyHand\JsonApiToolsBundle\ApiResource;

class Attribute
{
    /**
     * Name of the attribute
     * @var string
     */
    private $name;

    /**
     * Name of the attribute in json
     * @var string
     */
    private $jsonName;

    /**
     * Property linked to the attribute
     * @var string
     */
    private $property;

    /**
     * Entity whose property it is
     * @var string
     */
    private $entity;

    /**
     * Sortable
     * @var boolean
     */
    private $sortable;

    /**
     * Read Only
     * @var boolean
     */
    private $readOnly;

    /**
     * Formatter
     * @var Formatter
     */
    private $formatter;

    /**
     * Input Only
     * @var boolean
     */
    private $inputOnly;

    /**
     * Constructor
     * @param string $name Name of the attribute
     */
    public function __construct($name)
    {
        $this->name = $name;
    }

    /**
     * Add the attribute value to the json outpu
     * @param  mixed $entity Entity or entity collection
     * @param  array $json   Hash for json output
     * @return array         Altered json hash
     */
    public function addToJson($entity, array $json)
    {
        if (is_array($entity)) {
            if (array_key_exists($this->getEntity(), $entity)) {
                $json['attributes'][$this->getJsonName()] = $this->getFormatter()->toJson($entity[$this->getEntity()]->{'get' . ucfirst($this->property)}());
            }
        } else {
            $json['attributes'][$this->getJsonName()] = $this->getFormatter()->toJson($entity->{'get' . ucfirst($this->property)}());
        }

        return $json;
    }

    /**
     * Add the attribute back to the entity
     * @param  mixed $entity Entity or entity collection
{'fraction_non_alphanumeric': 0.13534675615212527, 'fraction_numerical': 0.0, 'mean_word_length': 1.8707865168539326, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '6685756', 'n_tokens_mistral': 1047, 'n_tokens_neox': 1023, 'n_words': 272}