Wire::className PHP Method

className() public method

Note that it caches the class name in the $className object property to reduce overhead from calls to get_class().
public className ( array | null $options = null ) : string
$options array | null Optionally an option: - lowercase (bool): Specify true to make it return hyphenated lowercase version of class name
return string
    public function className($options = null)
    {
        if (!$this->className) {
            $this->className = get_class($this);
        }
        if ($options === null || !is_array($options)) {
            return $this->className;
        }
        if (!empty($options['lowercase'])) {
            if (!empty($this->classNameOptions['lowercase'])) {
                return $this->classNameOptions['lowercase'];
            }
            $name = $this->className;
            $part = substr($name, 1);
            if (strtolower($part) != $part) {
                // contains more than 1 uppercase character, convert to hyphenated lowercase
                $name = substr($name, 0, 1) . preg_replace('/([A-Z])/', '-$1', $part);
            }
            $name = strtolower($name);
            $this->classNameOptions['lowercase'] = $name;
            return $name;
        }
        return $this->className;
    }

Usage Example

 /**
  * Get all debug info for the given Wire object
  * 
  * @param Wire $obj
  * @return array
  * 
  */
 public function getDebugInfo(Wire $obj)
 {
     $className = $obj->className();
     $info = array();
     if (method_exists($this, $className)) {
         $info = array_merge($info, $this->{$className}($obj));
     }
     $changes = $obj->getChanges();
     if (count($changes)) {
         $info['changes'] = $changes;
     }
     $hooks = $this->getHooksInfo($obj);
     if (count($hooks)) {
         $info['hooks'] = $hooks;
     }
     return $info;
 }