<commit_before><?php

use XeroPHP\Remote\Object;

class Property {

    private $model; //this is required so you can search the other models/enums

    private $type;
    private $name;
    private $description;
    private $links;

    private $is_deprecated;
    private $is_mandatory;
    private $is_read_only;

    /**
     * Contains the model that a property contains
     *
     * @var Model $related_object
     */
    private $related_object;

    public $save_directly;

    public function __construct($name, $description, $mandatory = false, $read_only = false, $deprecated = false){
        if(strpos($name, '(deprecated)')){
            $name = str_replace('(deprecated)', '', $name);
            $deprecated = true;
        }

        $this->is_deprecated = $deprecated;
        $this->is_mandatory = $mandatory;
        $this->is_read_only = $read_only;
        $this->name = $name;
        $this->description = $description;
        $this->links = array();
        $this->related_object = null;
        $this->save_directly = false;


    }

    /**
     * @param Model $model
     */
    public function setModel(Model $model){
        //called by the model.
        $this->model = $model;
    }

    /**
     * @return Model
     */
    public function getModel(){
        return $this->model;
    }

    /**
     * @return string
     */
    public function getName(){
        return $this->name;
    }

    /**
     * @return string
     */
    public function getNameSingular(){
        return \XeroPHP\Helpers::singularize($this->getName());
    }

    /**
     * @return string
     */
    public function getDescription(){
        return $this->description;
    }

    /**
     * @return Model|null
     */
    public function getRelatedObject(){
        return $this->related_object;
    }

    /**
     * @return bool
     */
    public function isDeprecated(){
        return $this->is_deprecated;
    }

    /**
     * @return bool
     */
    public function isMandatory(){
        return $this->is_mandatory;
    }

    public function isReadOnly(){
        return $this->is_read_only;
    }

    /**
     * @param $text
     * @param $href
     */
    public function addLink($text, $href){
        $this->links[] = array(
            'text' => $text,
            'href' => $href
        );
    }

    /**
     * @return bool
     */
    public function isArray(){

        switch(true){
            case stripos($this->getName(), 'status') !== false:
            case $this->getType() === Object::PROPERTY_TYPE_BOOLEAN:
            case $this->getType() === Object::PROPERTY_TYPE_ENUM:
                return false;
            //This to to improve detection of names that are the same plural/sing
            case preg_match('/maximum of [2-9] <(?<model>[a-z]+)> elements/i', $this->getDescription()):
                return true;
            default:
                return $this->getNameSingular() != $this->getName();
        }

    }

    /**
     * @return string
     */
    public function getType(){

        if(!isset($this->type))
            $this->type = $this->parseType();

        return $this->type;
    }

    public function getTypeConstant(){
        //Ew.
        $rc = new ReflectionClass('\\XeroPHP\\Remote\\Object');
        foreach($rc->getConstants() as $constant_name => $constant_value)
            if($constant_value === $this->getType())
                return $constant_name;

        return null;
<commit_msg>Shouldn't ever be necessary for there to be arrays of strings<commit_after><?php

use XeroPHP\Remote\Object;

class Property {

    private $model; //this is required so you can search the other models/enums

    private $type;
    private $name;
    private $description;
    private $links;

    private $is_deprecated;
    private $is_mandatory;
    private $is_read_only;

    /**
     * Contains the model that a property contains
     *
     * @var Model $related_object
     */
    private $related_object;

    public $save_directly;

    public function __construct($name, $description, $mandatory = false, $read_only = false, $deprecated = false){
        if(strpos($name, '(deprecated)')){
            $name = str_replace('(deprecated)', '', $name);
            $deprecated = true;
        }

        $this->is_deprecated = $deprecated;
        $this->is_mandatory = $mandatory;
        $this->is_read_only = $read_only;
        $this->name = $name;
        $this->description = $description;
        $this->links = array();
        $this->related_object = null;
        $this->save_directly = false;


    }

    /**
     * @param Model $model
     */
    public function setModel(Model $model){
        //called by the model.
        $this->model = $model;
    }

    /**
     * @return Model
     */
    public function getModel(){
        return $this->model;
    }

    /**
     * @return string
     */
    public function getName(){
        return $this->name;
    }

    /**
     * @return string
     */
    public function getNameSingular(){
        return \XeroPHP\Helpers::singularize($this->getName());
    }

    /**
     * @return string
     */
    public function getDescription(){
        return $this->description;
    }

    /**
     * @return Model|null
     */
    public function getRelatedObject(){
        return $this->related_object;
    }

    /**
     * @return bool
     */
    public function isDeprecated(){
        return $this->is_deprecated;
    }

    /**
     * @return bool
     */
    public function isMandatory(){
        return $this->is_mandatory;
    }

    public function isReadOnly(){
        return $this->is_read_only;
    }

    /**
     * @param $text
     * @param $href
     */
    public function addLink($text, $href){
        $this->links[] = array(
            'text' => $text,
            'href' => $href
        );
    }

    /**
     * @return bool
     */
    public function isArray(){

        switch(true){
            case stripos($this->getName(), 'status') !== false:
            case $this->getType() === Object::PROPERTY_TYPE_BOOLEAN:
            case $this->getType() === Object::PROPERTY_TYPE_ENUM:
            case $this->getType() === Object::PROPERTY_TYPE_STRING:
                return false;
            //This to to improve detection of names that are the same plural/sing
            case preg_match('/maximum of [2-9] <(?<model>[a-z]+)> elements/i', $this->getDescription()):
                return true;
            default:
                return $this->getNameSingular() != $this->getName();
        }

    }

    /**
     * @return string
     */
    public function getType(){

        if(!isset($this->type))
            $this->type = $this->parseType();

        return $this->type;
    }

    public function getTypeConstant(){
        //Ew.
        $rc = new ReflectionClass('\\XeroPHP\\Remote\\Object');
        foreach($rc->getConstants() as $constant_name => $constant_value)
            if($constant_value === $this->getType())
                return $constant_name;

        return null;

{'fraction_non_alphanumeric': 0.14035087719298245, 'fraction_numerical': 0.0005659309564233164, 'mean_word_length': 1.9138499587798845, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 74, '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': '7124916', 'n_tokens_mistral': 2055, 'n_tokens_neox': 2019, 'n_words': 471}