Back to BaseModel class

Method getName

public string
getName
()
Method to get the model name
Returns
  • string The name of the model
Since
  • 4.0.0
-
  • \Exception
Class: BaseModel
Project: Joomla

Method getName - Source code

/**
 * Method to get the model name
 *
 * The model name. By default parsed using the classname or it can be set
 * by passing a $config['name'] in the class constructor
 *
 * @return  string  The name of the model
 *
 * @since   4.0.0
 * @throws  \Exception
 */
public function getName()
{
    if (empty($this->name)) {
        $r = null;
        if (!preg_match('/Model(.*)/i', \get_class($this), $r)) {
            throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_GET_NAME', __METHOD__), 500);
        }
        $this->name = str_replace(['\\', 'model'], '', strtolower($r[1]));
    }
    return $this->name;
}