Tries to guess Block controller class name if $className is empty.

@return string
768318
private function guessControllerClass()
	{
		$calledClass = get_called_class();

		if (($pos = strpos($calledClass, 'Config')) !== false
				&& $pos === (strlen($calledClass) - 6)
				&& class_exists(($className = substr($calledClass, 0, -6)))) {

			return $className;
		}

		return  '\Supra\Package\Cms\Pages\Block\DefaultBlockController';
	}
531655
public function getMyType() {
        $className = get_class($this);
        $classParts = explode("\\", $className);
        $classSingle = $classParts[count($classParts) - 1];
        $classLowSingle = strtolower($classSingle);
        $type = str_replace("message", "", $classLowSingle);

        if (!$type) {
            return "unknown";
        } else {
            return $type;
        }
    }
228917
public function detectControllerName()
    {
        $pattern = '#/'.$this->controllerNameRegex().'#i';
        if (!preg_match($pattern, $this->path, $matches)) {
            return false;
        }

        return $matches[1];
    }
352239
public function getClassName() {
        $fileSource = $this->fileSpecification->getSource();
        return (new fphp\Helper\PhpParser())->parseFile($fileSource)->getExactlyOneClass($fileSource)->name;
    }
757173
private function getControllerClassName() : string
    {
        $tableName = App::shortName(get_class($this->table), 'Model/Table', 'Table');

        return (string)App::className($tableName . 'Controller', 'Controller');
    }
318535
function getClassName() {
    	preg_match('/\[\s\<\w+?>\s([\w\\\\]+)/s', $this->__toString(), $matches);
    	$class = isset($matches[1]) ? $matches[1] : null;
        if(in_array($class, [ 'array', 'string', 'char', 'bool', 'boolean', 'int', 'integer', 'double', 'float', 'real', 'mixed', 'number', 'null', 'callable', 'callback' ])) {
            return null;
        }
        return $class;
    }
956004
public function extractClassName()
    {
        $tokens = token_get_all($this->phpCode);
        $numberOfTokens = count($tokens);
        for ($i = 0; $i < $numberOfTokens; $i++) {
            $token = $tokens[$i];
            if (is_string($token) || $token[0] !== T_CLASS) {
                continue;
            }
            for (++$i; $i < $numberOfTokens; $i++) {
                $token = $tokens[$i];
                if (is_string($token)) {
                    break;
                }
                list($type, $value) = $token;
                if ($type === T_STRING) {
                    return $value;
                }
                if ($type !== T_WHITESPACE) {
                    break;
                }
            }
        }
        return null;
    }
110105
public function getControllerActionName()
    {
        $controllerObjectName = $this->getControllerObjectName();
        if ($controllerObjectName !== '' && ($this->controllerActionName === strtolower($this->controllerActionName))) {
            $controllerClassName = $this->objectManager->getClassNameByObjectName($controllerObjectName);
            $lowercaseActionMethodName = strtolower($this->controllerActionName) . 'action';
            foreach (get_class_methods($controllerClassName) as $existingMethodName) {
                if (strtolower($existingMethodName) === $lowercaseActionMethodName) {
                    $this->controllerActionName = substr($existingMethodName, 0, -6);
                    break;
                }
            }
        }
        return $this->controllerActionName;
    }
1220952
public function getControllerClass()
    {
        $controller = array_get($this->routeParams, 'controller');
        $match      = null;
        if (!preg_match('/(.*?)(?=@|$)/', $controller, $match)) {
            return;
        }
        return $match[0];
    }
369549
public function findClassName($className)
    {
        if (!empty($this->lookupCache->classes[$className])) {
            return $this->lookupCache->classes[$className];
        }

        if (class_exists($className)) return $className;
        $startsWithSlash = ($className[0] == '\\');

        foreach ($this->searchOrder as $namespace)
        {
            $testClass = '\\' . $namespace;
            if (!$startsWithSlash) {
                $testClass .= '\\';
            }

            $testClass .= $className;

            if (class_exists($testClass)) {
                $this->lookupCache->classes[$className] = $testClass;
                return $testClass;
            }
        }

        return null;
    }
365353
public function getShortName()
    {
        $value = $this->getValue();
        if (empty($value) || !ClassInfo::exists($value)) {
            return null;
        }
        return ClassInfo::shortName($value);
    }
694334
public function getControllerName($type = 'plural')
    {
        if ($type == 'singular') {
            // auto calc if not already set
            if ($this->singularName == null) {
                $className = get_called_class();
                $config = $this->getDI()->get('config');
                $className = str_replace($config['namespaces']['controllers'], '', $className);
                $className = str_replace('Controller', '', $className);
                $this->singularName = $className;
            }
            return $this->singularName;
        } elseif ($type == 'plural') {
            // auto calc most common plural
            if ($this->pluralName == null) {
                // this could be better, just adding an s by default
                $this->pluralName = $this->getControllerName('singular') . 's';
            }
            return $this->pluralName;
        }

        // todo throw error here
        return false;
    }
577794
public function autoDetectModuleNameByClassName($className)
    {
        if (array_key_exists($className, $this->classNameToModuleName)) {
            $resultModuleName =  $this->classNameToModuleName[$className];
        } else {
            $index = $this->getModulesIndex();
            $classNameLength = strlen($className);

            $resultModuleName = null;
            foreach ($index as $moduleName => $moduleNameLength) {
                if ($classNameLength > $moduleNameLength && 0 === strrpos($className, $moduleName)) {
                    $resultModuleName = $moduleName;
                    break;
                }
            }
            $this->classNameToModuleName[$className] = $resultModuleName;
        }

        return $resultModuleName;
    }
284414
public function getUrlByClassName($className)
    {
        if (is_object($className)) $className = get_class($className);
        if (isset($this->known[$className]['config']['mount'])) {
            return $this->known[$className]['config']['mount'];
        } else {
            return null;
        }
    }
960930
public function getControllerName()
    {
        //default controller for SiteTree objects
        $controller = CatalogueController::class;

        //go through the ancestry for this class looking for
        $ancestry = ClassInfo::ancestry($this->owner->ClassName);

        // loop over the array going from the deepest descendant (ie: the current class) to SiteTree
        while ($class = array_pop($ancestry)) {
            //we don't need to go any deeper than the SiteTree class
            if ($class == CatalogueProduct::class || $class == CatalogueCategory::class) {
                break;
            }
            
            // If we have a class of "{$ClassName}Controller" then we found our controller
            if (class_exists($candidate = sprintf('%sController', $class))) {
                $controller = $candidate;
                break;
            } elseif (class_exists($candidate = sprintf('%s_Controller', $class))) {
                // Support the legacy underscored filename, but raise a deprecation notice
                Deprecation::notice(
                    '5.0',
                    'Underscored controller class names are deprecated. Use "MyController" instead of "My_Controller".',
                    Deprecation::SCOPE_GLOBAL
                );
                $controller = $candidate;
                break;
            }
        }

        return $controller;
    }
1190592
public function getControllerShortName()
    {
        $relativeUrl = $this->request->getUri()->getPath();

        $rootUrl = parse_url(ROOT_URL);
        if (isset($rootUrl['path'])) {
            $rootUrlPath = $rootUrl['path'];
            $relativeUrl = str_replace(rtrim($rootUrlPath, '/'), '', $relativeUrl);
        }

        $parts = explode('/', trim($relativeUrl, '/'));
        if(count($parts) === 3){
            return $parts[1];
        }

        return null;
    }
935194
public function name(): string
    {
        static $name = null;
        if ($name === null) {
            // Extract command name from the class name.
            $class = substr(strrchr(static::class, '\\'), 1);
            $name = CommandLoader::inverseTranslate($class);
        }

        return $name;
    }