/**
 * Method to get state variables.
 *
 * @param   string  $property  Optional parameter name
 * @param   mixed   $default   Optional default value
 *
 * @return  mixed  The property where specified, the state object where omitted
 *
 * @since   4.0.0
 */
public function getState($property = null, $default = null)
{
    if ($this->state === null) {
        $this->state = new CMSObject();
    }
    if (!$this->__state_set) {
        // Protected method to auto-populate the state
        $this->populateState();
        // Set the state set flag to true.
        $this->__state_set = true;
    }
    return $property === null ? $this->state : $this->state->get($property, $default);
}