Converts class to name

@param string  $class
@param integer $type  Mask type

@return string

@throws InvalidArgumentException
332448
public static function classToName($class, $type)
    {
        if (!class_exists($class)) {
            throw new InvalidArgumentException(
                "Class '" . $class . "' not found!"
            );
        }
        $class = self::_trimNamespace($class);

        if (!isset(self::$masks[$type])) {
            throw new InvalidArgumentException(
                "Invalid mask type " . $type . "!"
            );
        }

        $mask = self::_trimNamespace(self::$masks[$type]);

        if ($mask === "*") {
            return $class;
        }

        preg_match("/" . str_replace("*", "(.*)", $mask) . "/", $class, $match);
        return $match[1];
    }
388052
public function setConstraintClass($name, $class)
    {
        // Ensure class exists
        if (!class_exists($class)) {
            throw new InvalidArgumentException('Unknown constraint ' . $name);
        }
        // Ensure class is appropriate
        if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
            throw new InvalidArgumentException('Invalid class ' . $name);
        }
        $this->constraintMap[$name] = $class;

        return $this;
    }
1318867
private static function createCallmapProxyCode(\ReflectionClass $class): string
    {
        if ($class->isFinal()) {
            throw new \InvalidArgumentException(
                    'Can not create mapping proxy for final class '
                    . $class->getName()
            );
        }

        $code = self::createClassDefinition($class)
                . self::createMethods($class)
                . "}\n";
        if ($class->inNamespace()) {
            return sprintf(
                    "namespace %s {\n%s}\n",
                    $class->getNamespaceName(),
                    $code
            );
        }

        return $code;
    }
1199155
protected function buildClassName($class, $extends = '', $implements = '')
    {
        $classname = $this->namespace . '\\' . $class;
        if (! class_exists($classname)) {
            throw new \LogicException("Class $classname does not exists");
        }
        if ('' !== $extends) {
            if (! in_array($extends, class_parents($classname))) {
                throw new \LogicException("Class $classname does not extends $extends");
            }
        }
        if ('' !== $implements) {
            if (! in_array($implements, class_implements($classname))) {
                throw new \LogicException("Class $classname does not implements $implements");
            }
        }
        return $classname;
    }
1351127
protected function getShortName($class, $type)
    {
        // 获取类名中,类型之后的半段
        // 如Miaoxing\User\Controller\Admins\User返回Admin\User
        $name = explode('\\' . $type . '\\', $class, 2)[1];

        // 将名称转换为小写
        $pos = strrpos($name, '\\');
        $pos = $pos === false ? 0 : $pos + 1;
        $name[$pos] = lcfirst($name[$pos]);
        $name = lcfirst($name);

        return $name;
    }
820690
private function getObjectMapping(string $class): ValidationMappingProviderInterface
    {
        try {
            return $this->validatorObjectMappingRegistry->provideMapping($class);
        } catch (ValidatorLogicException $exception) {
            $this->logger->error('validate: {exception}', ['exception' => $exception->getMessage()]);

            throw $exception;
        }
    }
614602
private function load($class)
    {
        if ($this->isLoaded($class)) {
            throw new \InvalidArgumentException(sprintf(
                "Error loading class '%s', the class already exists",
                $class
            ));
        }

        if ($file = $this->findFile($class)) {
            return $this->loadFile($file, $class);
        }

        return false;
    }
93476
public static function get(string $type): Transform
    {
        $namespace = '\\ModelHistory\\Model\\Transform\\';
        $transformClass = $namespace . Inflector::camelize($type) . 'Transform';
        if (class_exists($transformClass)) {
            return new $transformClass();
        }
        throw new InvalidArgumentException('Transform ' . $transformClass . ' not found!');
    }
371975
private function getObjectMapping(string $class): DenormalizationObjectMappingInterface
    {
        try {
            return $this->denormalizerObjectMappingRegistry->getObjectMapping($class);
        } catch (DeserializerLogicException $exception) {
            $this->logger->error('deserialize: {exception}', ['exception' => $exception->getMessage()]);

            throw $exception;
        }
    }
602565
public function extractName($class)
    {
        foreach ($this->extractors as $extractor) {
            if ($extractor->canExtractName($class)) {
                return $extractor->extractName($class);
            }
        }

        throw new \InvalidArgumentException();
    }
352378
protected function instantiateClass($class)
    {
        try {
            $instance = app($class);

        } catch (BindingResolutionException $e) {

            throw new InvalidArgumentException(
                "Failed to instantiate Module or ModuleGenerator instance for '{$class}'",
                $e->getCode(),
                $e
            );

        } catch (ReflectionException $e) {

            throw new InvalidArgumentException(
                "Failed to instantiate Module or ModuleGenerator instance for '{$class}'",
                $e->getCode(),
                $e
            );
        }

        if (    ! ($instance instanceof ModuleInterface)
            &&  ! ($instance instanceof ModuleGeneratorInterface)
        ) {
            throw new InvalidArgumentException(
                "Expected ModuleInterface or ModuleGeneratorInterface, got '{$class}'"
            );
        }

        return $instance;
    }
1144492
private function psr4_get_file_name_from_class( $class ) {
		$class = strtolower( $class );
		if ( stristr( $class, '\\' ) ) {

			// If the first item is == the collection name, trim it off.
			$class = str_ireplace( static::$autoload_class_prefix, '', $class );

			// Maybe fix formatting underscores to dashes and double to single slashes.
			$class     = str_replace( [ '_', '\\' ], [ '-', '/' ], $class );
			$class     = explode( '/', $class );
			$file_name = &$class[ count( $class ) - 1 ];
			$file_name = static::$filename_prefix . $file_name . '.php';
			$file_path = join( DIRECTORY_SEPARATOR, $class );

			return $file_path;
		} else {
			return static::$filename_prefix . str_replace( '_', '-', $class ) . '.php';
		}
	}
649444
public function setProvider($class, $provider)
    {

        ltrim($class, '\\');

        if ($provider instanceof Provider) {
            $this->providers[$class] = $provider;
            return $this;
        }

        if (is_callable($provider)) {
            $this->providerFactories[$class] = $provider;
            return $this;
        }

        if (!is_string($provider)) {
            throw new InvalidArgumentException("Provider has to be callable, Provider or a class name.");
        }

        $this->providerFactories[$class] = function () use ($provider) {
            return $this->createObject($provider);
        };

        return $this;
    }
209774
public static function fromClassname($class)
    {
        try {
            if (!class_exists($class)) {
                throw new InvalidArgumentException(sprintf('The class "%s" does not exist', $class));
            }

            return new self(ClassUtils::getRealClass($class), 'class');
        } catch (InvalidArgumentException $e) {
            throw new InvalidSubjectIdentityException($e->getMessage(), 0, $e);
        }
    }
266906
public function unformatPresenterClass(string $class): ?string
    {
        $presenter = array_search($class, $this->presenterMapping, true);
        if ($presenter !== false) {
            return (string) $presenter;
        }

        foreach ($this->moduleMapping as $module => $mapping) {
            $mapping = str_replace(['\\', '*'], ['\\\\', '(\w+)'], $mapping);
            $matches = Strings::match($class, "#^\\\\?$mapping[0]((?:$mapping[1])*)$mapping[2]\\z#i");
            if ($matches !== null) {
                return ($module === '' ? '' : $module . ':') . Strings::replace($matches[1], "#$mapping[1]#iA", '$1:') . $matches[3];
            }
        }

        return null;
    }
730908
public function setTypeMapping($type, $class = null)
    {
        if (is_string($type)) {
            if ($class === null) {
                throw new InvalidArgumentException(
                    'If $type is specified, $class is required'
                );
            }
            $type = array($type => (string) $class);
            $class = null;
        }

        if (!is_array($type)) {
            throw new InvalidArgumentException(
                'Type must either be an array or a string.'
            );
        }

        if ($class !== null) {
            throw new InvalidArgumentException(
                'If $type is an array, $class must not be specified.'
            );
        }

        $this->type_map = array_merge($this->type_map, $type);
    }
896688
public static function addType($type, $class)
    {
        if (static::hasType($type)) {
            throw TypeException::typeAlreadyExists($type);
        }

        if (!class_exists($class)) {
            throw TypeException::classNotFound($class);
        }

        if (!in_array('Fridge\DBAL\Type\TypeInterface', class_implements($class))) {
            throw TypeException::typeMustImplementTypeInterface($class);
        }

        static::$mappedTypeClasses[$type] = $class;
    }