Formats a class name for readable use in the response

@param $class Class name to format
@return string Formatted name
334894
private function getFormattedName($class)
    {
        $class_name = (substr(strrchr(get_class($class), "\\"), 1));
        $underscored = preg_replace('/([a-z])([A-Z])/', '$1_$2', $class_name);

        return strtolower($underscored);
    }
788281
private function dumpLiteralClass(string $class): string
    {
        if (false !== strpos($class, '$')) {
            return sprintf('${($_ = %s) && false ?: "_"}', $class);
        }
        if (0 !== strpos($class, "'") || !preg_match('/^\'(?:\\\{2})?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(?:\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) {
            throw new RuntimeException(sprintf('Cannot dump definition because of invalid class name (%s)', $class ?: 'n/a'));
        }

        $class = substr(str_replace('\\\\', '\\', $class), 1, -1);

        return 0 === strpos($class, '\\') ? $class : '\\'.$class;
    }
1252238
protected function getValidAlgorithm($class)
    {
        $logging = \Plop\Plop::getInstance();;
        $w =    'abcdefghijklmnopqrstuvwxyz' .
                'ABCDEFGHIJKLMNOPQRSTUVWXYZ' .
                '1234567890-@.';
        $name = $class::getName();
        if (!is_string($name) || strspn($name, $w) !== strlen($name)) {
            $logging->debug(
                'Skipping algorithm "%(name)s" (invalid algorithm name)',
                array('name' => $name)
            );
            return null;
        }
        return $name;
    }
850526
public function getBundleName($class)
    {
        $reflector = new \ReflectionClass(get_class($class));

        return ($p1 = strpos($ns = $reflector->getNamespaceName(), '\\')) === false ? $ns :
            substr($ns, 0, ($p2 = strpos($ns, '\\', $p1 + 1)) === false ? strlen($ns) : $p2);
    }
936775
protected function get_file_name( $class ) {
		if ( $class ) {
			$file   = explode( '\\', $class );
			$file   = strtolower( end( $file ) );
			$file__ = str_replace( '_', '-', $file );
			$files  = array(
				$file . '.php', // File Name With _.
				$file__ . '.php', // File Name With - which is replaced by _.
				'class-' . $file__ . '.php', // File name With Class Prefixed.
				'class_' . $file__ . '.php', // File Name With - which is replaced by _.
			);
			return $files;
		}
		return false;
	}
222879
public static function className($class)
    {
        $result = App::className($class, 'Model/Behavior', 'Behavior');
        if (!$result) {
            $result = App::className($class, 'ORM/Behavior', 'Behavior');
        }

        return $result ?: null;
    }
382612
private function getClassConsts($class)
    {
        $result = '';
        foreach($class->getConstants() as $name => $value)
        {
            $value = var_export($value, true);
            $result .= <<<CODE

    const {$name} = $value;

CODE;
        }
        return $result;
    }
336695
public static function getClassShortName(
        string $class,
        string $suffix = ''
    ): string {
        $baseName = static::getClassBaseName($class);

        return preg_replace(sprintf('/%s$/', $suffix), '', $baseName);
    }
229904
public static function tableize($class)
    {
        $underscored = Strings::camelCaseToUnderscore($class);
        $parts = explode('_', $underscored);
        $suffix = Inflector::pluralize(array_pop($parts));
        $parts[] = $suffix;
        return implode('_', $parts);
    }
1000621
private function getName($class)
    {
        $class = preg_replace('/(.*[^\\\]+)Interface$/', '$1', $class);

        if (isset($this->entityOverride[$class])) {
            $class = $this->entityOverride[$class];
        }
        if ($this->sectionConfig->hasSection($class)) {
            return $this->sectionConfig->getSection($class)->getAlias();
        }

        return $this->objectNamer->name($class);
    }
898882
public function resolve($class)
    {
        $result = false;
        $prefix = $class;

        while (false !== ($pos = strrpos($prefix, '\\'))) {
            $prefix = substr($class, 0, $pos + 1);

            if (isset($this->prefixes[$prefix])) {
                $result = $this->resolveFilename($prefix, str_replace('\\', '/', substr($class, $pos + 1)));

                if ($result !== false) {
                    break;
                }
            }

            $prefix = rtrim($prefix, '\\');
        }

        return $result;
    }
153018
private function generateProxyShortClassName(ClassMetadata $class)
    {
        $proxyClassName = ClassUtils::generateProxyClassName($class->getName(), $this->proxyNamespace);
        $parts          = explode('\\', strrev($proxyClassName), 2);

        return strrev($parts[0]);
    }
440773
public static function loadClass($class) {
    	
        //The current namespace prefix
        $prefix = $class;

        //Work backwards through the namespace names of the fully-qualified class name to find a mapped file name
        while(false !== $pos = strrpos($prefix, '\\')) {

            //Retain the trailing namespace separator in the prefix
            $prefix = substr($class, 0, $pos + 1);

            //The rest is the relative class name
            $relative_class = substr($class, $pos + 1);

            //Try to load a mapped file for the prefix and relative class
            $mapped_file = static :: loadMappedFile($prefix, $relative_class);

            if(false !== $mapped_file) {
                return $mapped_file;
            }

            //Remove the trailing namespace separator for the next iteration of strrpos()
            $prefix = rtrim($prefix, '\\');
        }

        //Never found a mapped file
        return false;
    }
656937
public function setClass($class = '')
    {
        if (is_string($class) && (empty($class) === true || Format::isClass($class) === true)) {
            $class = trim($class);
            $this->class = $class;
        } else {
            $msg = "The 'class' argument must be a valid class name, '" . $class . "' given";
            throw new InvalidArgumentException($msg);
        }
    }
391599
protected function transform($class)
    {
        if ($this->options->getBootstrapVersion() > 2) {
            foreach ($this->options->getCssClassmap() as $search => $replace) {
                $pattern = '/' . $search . '/i';
                if (preg_match($pattern, $class, $matches)) {
                    $done = str_replace($search, $replace, $class);

                    return $done;
                }
            }
        }

        return $class;
    }
485195
public static function parseRelationClass($class)
    {
        // detect many many through syntax
        if (is_array($class)
            && array_key_exists('through', $class)
            && array_key_exists('to', $class)
        ) {
            $toRelation = $class['to'];

            $hasOne = Config::inst()->get($class['through'], 'has_one');
            if (empty($hasOne) || !is_array($hasOne) || !array_key_exists($toRelation, $hasOne)) {
                return $class;
            }

            return $hasOne[$toRelation];
        }

        return $class;
    }
1179448
private function formatClassName($className)
    {
        $prefix   = ' ==> ';
        $ellipsis = '...';
        $suffix   = '   ';
        if ($this->hideNamespace && strrpos($className, '\\')) {
            $className = substr($className, strrpos($className, '\\') + 1);
        }
        $formattedClassName = $prefix . $className . $suffix;

        if (\strlen($formattedClassName) <= $this->maxClassNameLength) {
            return $this->fillWithWhitespace($formattedClassName);
        }

        // maxLength of class, minus leading (...) and trailing space
        $maxLength = $this->maxClassNameLength - \strlen($prefix . $ellipsis . $suffix);

        // substring class name, providing space for ellipsis and one space at end
        // this result should be combined to equal $this->maxClassNameLength
        return $prefix . $ellipsis . substr($className, \strlen($className) - $maxLength, $maxLength) . $suffix;
    }