<commit_before>{{ '<?php' }}

namespace XeroPHP\Models\{{ model.Namespace }};

use XeroPHP\Remote;

{% if model.SupportsPDF %}
use XeroPHP\Traits\PDFTrait;
{% endif %}
{% if model.SupportsAttachments %}
use XeroPHP\Traits\AttachmentTrait;

{% endif %}
{% for class in model.UsedClasses %}
use XeroPHP\Models\{{ class }};
{% endfor %}

class {{ model.ClassName }} extends Remote\Object {

{% if model.SupportsPDF %}
    use PDFTrait;
{% endif %}
{% if model.SupportsAttachments %}
    use AttachmentTrait;

{% endif %}
{% for property in model.Properties %}
    /**
     * {{ property.Description|wordwrap(100, "\n     * ")|raw }}
     *
     * @property {{ property.PHPType }}{% if property.isArray %}[]{% endif %} {{ property.Name }}
{% if property.isDeprecated %}     * @deprecated
{% endif %}
     */

{% endfor %}

{% for enum in model.Enums %}
{% for enum_value in enum.Values %}
    const {{ enum_value.constant_name }} = '{{ enum_value.value }}';{% if enum.description %} // {{ enum_value.description }}{% endif %}

{% endfor %}

{% endfor %}

    /**
     * Get the resource uri of the class (Contacts) etc
     *
     * @return string
     */
    public static function getResourceURI(){
        return '{{ model.ResourceURI }}';
    }


    /**
     * Get the root node name.  Just the unqualified classname
     *
     * @return string
     */
    public static function getRootNodeName(){
        return '{{ model.ClassName }}';
    }


    /**
     * Get the guid property
     *
     * @return string
     */
    public static function getGUIDProperty(){
        return '{{ model.GUIDProperty.Name }}';
    }


    /**
     * Get the stem of the API (core.xro) etc
     *
     * @return string|null
     */
    public static function getAPIStem(){
        return {% if model.API.StemConstant %}Remote\URL::{{ model.API.StemConstant }}{% else %}null{% endif %};
    }


    /**
     * Get the supported methods
     */
    public static function getSupportedMethods() {
        return array(
{% for method in model.Methods %}
            Remote\Request::METHOD_{{ method }}{% if not loop.last %},{% endif %}

{% endfor %}
        );
    }

    /**
     *
     * Get the properties of the object.  Indexed by constants
     *  [0] - Mandatory
     *  [1] - Type
     *  [2] - PHP type
     *  [3] - Is an Array
     *  [4] - Saves directly
     *
     * @return array
     */
    public static function getProperties() {
        return array(
{% for property in model.Properties %}
            '{{ property.name }}' => array ({% if property.isMandatory %}true{% else %}false{% endif %}, self::{{ property.getTypeConstant }}, {% if property.isHintable %}'{{ property.getPHPType(true)|addslashes }}'{% else %}null{% endif %}, {% if property.isArray %}true{% else %}false{% endif %}, {% if property.save_directly %}true{% else %}false{% endif %}){% if not loop.last %},{% endif %}

{% endfor %}
        );
    }

    public static function isPageable(){
        return {% if model.isPageable %}true{% else %}false{% endif %};
    }

{#  getters and setters #}
{% for property in model.properties %}
    /**
     * @return {{ property.PHPType }}{% if property.isArray %}[]|Remote\Collection
     * Always returns a collection, switch is for type hinting{% endif %}

{% if property.isDeprecated %}     * @deprecated
{% endif %}
     */
    public function get{{ property.Name }}() {
        return $this->_data['{{ property.Name }}'];
    }

{% if property.isReadOnly == false %}
    /**
     * @param {{ property.PHPType }} $value
     * @return {{ model.ClassName }}
{% if property.isDeprecated %}     * @deprecated
{% endif %}
     */
    public function {% if property.isArray %}add{% else %}set{% endif %}{{ property.NameSingular }}({% if property.isHintable %}{{ property.PHPType }} {% endif %}$value) {
        $this->propertyUpdated('{{ property.Name }}', $value);
        {% if property.isArray %}if(!isset($this->_data['{{ property.Name }}'])){
            $this->_data['{{ property.Name }}'] = new Remote\Collection();
        }
        $this->_data['{{ property.Name }}'][] = $value;
        {% else %}$this->_data['{{ property.Name }}'] = $value;
        {% endif %}return $this;
    }
{% endif %}

{% endfor %}

}<commit_msg>Update model template to PSR-2<commit_after>{{ '<?php' }}
namespace XeroPHP\Models\{{ model.Namespace }};

use XeroPHP\Remote;
{% if model.SupportsPDF %}
use XeroPHP\Traits\PDFTrait;
{% endif %}
{% if model.SupportsAttachments %}
use XeroPHP\Traits\AttachmentTrait;
{% endif %}
{% for class in model.UsedClasses %}
use XeroPHP\Models\{{ class }};
{% endfor %}

class {{ model.ClassName }} extends Remote\Object
{

{% if model.SupportsPDF %}
    use PDFTrait;
{% endif %}
{% if model.SupportsAttachments %}
    use AttachmentTrait;

{% endif %}
{% for property in model.Properties %}
    /**
     * {{ property.Description|wordwrap(100, "\n     * ")|raw }}
     *
     * @property {{ property.PHPType }}{% if property.isArray %}[]{% endif %} {{ property.Name }}
{% if property.isDeprecated %}     * @deprecated
{% endif %}
     */

{% endfor %}

{% for enum in model.Enums %}
{% for enum_value in enum.Values %}
    const {{ enum_value.constant_name }} = '{{ enum_value.value }}';{% if enum.description %} // {{ enum_value.description }}{% endif %}

{% endfor %}

{% endfor %}

    /**
     * Get the resource uri of the class (Contacts) etc
     *
     * @return string
     */
    public static function getResourceURI()
    {
        return '{{ model.ResourceURI }}';
    }


    /**
     * Get the root node name.  Just the unqualified classname
     *
     * @return string
     */
    public static function getRootNodeName()
    {
        return '{{ model.ClassName }}';
    }


    /**
     * Get the guid property
     *
     * @return string
     */
    public static function getGUIDProperty()
    {
        return '{{ model.GUIDProperty.Name }}';
    }


    /**
     * Get the stem of the API (core.xro) etc
     *
     * @return string|null
     */
    public static function getAPIStem()
    {
        return {% if model.API.StemConstant %}Remote\URL::{{ model.API.StemConstant }}{% else %}null{% endif %};
    }


    /**
     * Get the supported methods
     */
    public static function getSupportedMethods()
    {
        return array(
{% for method in model.Methods %}
            Remote\Request::METHOD_{{ method }}{% if not loop.last %},{% endif %}

{% endfor %}
        );
    }

    /**
     *
     * Get the properties of the object.  Indexed by constants
     *  [0] - Mandatory
     *  [1] - Type
     *  [2] - PHP type
     *  [3] - Is an Array
     *  [4] - Saves directly
     *
     * @return array
     */
    public static function getProperties()
    {
        return array(
{% for property in model.Properties %}
            '{{ property.name }}' => array ({% if property.isMandatory %}true{% else %}false{% endif %}, self::{{ property.getTypeConstant }}, {% if property.isHintable %}'{{ property.getPHPType(true)|addslashes }}'{% else %}null{% endif %}, {% if property.isArray %}true{% else %}false{% endif %}, {% if property.save_directly %}true{% else %}false{% endif %}){% if not loop.last %},{% endif %}

{% endfor %}
        );
    }

    public static function isPageable()
    {
        return {% if model.isPageable %}true{% else %}false{% endif %};
    }

{#  getters and setters #}
{% for property in model.properties %}
    /**
     * @return {{ property.PHPType }}{% if property.isArray %}[]|Remote\Collection
     * Always returns a collection, switch is for type hinting{% endif %}

{% if property.isDeprecated %}     * @deprecated
{% endif %}
     */
    public function get{{ property.Name }}()
    {
        return $this->_data['{{ property.Name }}'];
    }

{% if property.isReadOnly == false %}
    /**
     * @param {{ property.PHPType }} $value
     * @return {{ model.ClassName }}
{% if property.isDeprecated %}     * @deprecated
{% endif %}
     */
    public function {% if property.isArray %}add{% else %}set{% endif %}{{ property.NameSingular }}({% if property.isHintable %}{{ property.PHPType }} {% endif %}$value)
    {
        $this->propertyUpdated('{{ property.Name }}', $value);
        {% if property.isArray %}if(!isset($this->_data['{{ property.Name }}'])){
            $this->_data['{{ property.Name }}'] = new Remote\Collection();
        }
        $this->_data['{{ property.Name }}'][] = $value;
        {% else %}$this->_data['{{ property.Name }}'] = $value;
        {% endif %}return $this;
    }
{% endif %}

{% endfor %}

}

{'fraction_non_alphanumeric': 0.17723444080486664, 'fraction_numerical': 0.0019887693027608798, 'mean_word_length': 2.5725031341412454, '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': '2337607', 'n_tokens_mistral': 2840, 'n_tokens_neox': 2566, 'n_words': 652}