<commit_before><?php

namespace CL\LunaCore\Model;

/**
 * @author     <NAME>
 * @copyright  (c) 2014 Clippings Ltd.
 * @license    http://www.opensource.org/licenses/isc-license.txt
 */
trait DirtyTrackingTrait
{
    private $originals = [];

    public function setOriginals(array $attributes)
    {
        $this->originals = $attributes;
    }

    public function getOriginals()
    {
        return $this->originals;
    }

    public function getOriginal($name)
    {
        return isset($this->originals[$name]) ? $this->originals[$name] : null;
    }

    public function getChange($name)
    {
        if ($this->isAttributeChanged($name)) {
            return [$this->getOriginal($name), $this->$name];
        }
    }

    public function getChanges()
    {
        $changes = [];

        foreach ($this->originals as $name => $original) {
            if ($this->isAttributeChanged($name)) {
                $changes[$name] = $this->$name;
            }
        }

        return $changes;
    }

    public function isAttributeChanged($name)
    {
        return ($this->$name != $this->getOriginal($name));
    }

    public function isChanged()
    {
        foreach ($this->originals as $name => $orignial) {
            if ($this->isAttributeChanged($name)) {
                return true;
            }
        }
        return false;
    }
}
<commit_msg>:recycle: Property is more php-like<commit_after><?php

namespace CL\LunaCore\Model;

/**
 * @author     <NAME>
 * @copyright  (c) 2014 Clippings Ltd.
 * @license    http://www.opensource.org/licenses/isc-license.txt
 */
trait DirtyTrackingTrait
{
    private $originals = [];

    public function setOriginals(array $attributes)
    {
        $this->originals = $attributes;
    }

    public function getOriginals()
    {
        return $this->originals;
    }

    public function getOriginal($name)
    {
        return isset($this->originals[$name]) ? $this->originals[$name] : null;
    }

    public function getChange($name)
    {
        if ($this->isPropertyChanged($name)) {
            return [$this->getOriginal($name), $this->$name];
        }
    }

    public function getChanges()
    {
        $changes = [];

        foreach ($this->originals as $name => $original) {
            if ($this->isPropertyChanged($name)) {
                $changes[$name] = $this->$name;
            }
        }

        return $changes;
    }

    public function isPropertyChanged($name)
    {
        return ($this->$name != $this->getOriginal($name));
    }

    public function isChanged()
    {
        foreach ($this->originals as $name => $orignial) {
            if ($this->isPropertyChanged($name)) {
                return true;
            }
        }
        return false;
    }
}

{'fraction_non_alphanumeric': 0.14497469269703542, 'fraction_numerical': 0.0028922631959508315, 'mean_word_length': 2.0339912280701755, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '906535', 'n_tokens_mistral': 832, 'n_tokens_neox': 806, 'n_words': 158}