Return the fully qualified class name based on the use statements in
the current file.

@param string   $name
@param string[] $imports
@return string
549459
private static function fqcn($name, array $imports): string
    {
        // Already FQCN
        if ($name[0] === '\\') {
            return $name;
        }

        // Aliased
        if (array_key_exists($name, $imports)) {
            return '\\' . $imports[$name];
        }

        // Check other imports
        if ($plain = self::getPlainImportIfExists($name, $imports)) {
            return '\\' . $plain;
        }

        // Not a complex type, or otherwise unknown.
        return '';
    }
1210209
protected function getSlugFromName($name)
    {
        if( array_key_exists($name, self::$sluggedNames) ) {
            return self::$sluggedNames[$name];
        }

        return self::$sluggedNames[$name] = trim(Str::slug($name, '-'));
    }
408414
protected function appendSuffix(Name $class)
    {
        if ($class->isFullyQualified()) {
            if (count($class->parts) == 1) {
                return $class;
            }
            return $this->append(new Name('\\' . $class->toString()));
        }
        if ($this->isImport) {
            if (!$this->groupImport && count($class->parts) == 1) {
                return $class;
            }
            return $this->append($class);
        }
        foreach ($this->importNodes as $import) {
            if (strcmp($import->getLast(), $class->toString()) === 0) {
                return $class;
            }
        }
        return $this->append($class);
    }
528603
protected function getClassName($name)
    {
        $name = Util::normilizeClassName($name);

        $data = $this->getAll();

        $name = ucfirst($name);
        if (isset($data[$name])) {
            return $data[$name];
        }

        return false;
    }
438560
public function resolvePackage($name)
	{
		$packages = $this->getPackages();

		//most commonly we have Foobar or SupraPackageFoobar, which maps directly to package class
		//the other options is "foobar", which is mapped to AbstractPackage::getName
		foreach ($packages as $instance) {
			$class = get_class($instance);
			$classParts = explode('\\', $class);
			$className = $classParts[count($classParts) - 1];

			if ($name == $className || 'SupraPackage' . $name == $className) {
				return $class;
			}

			if ($name == $instance->getName()) {
				return $class;
			}
		}

		throw new \Exception(sprintf('Package "%s" can not be resolved', $name));
	}
295167
protected function checkForReservedClassName($name)
    {
        $name = trim(strtolower($name));

        if (in_array($name, config('pxlcms.generator.reserved', []))) {
            throw new \InvalidArgumentException("Cannot use {$name} as a module name, it is reserved!");
        }
    }
797333
protected function getCreateMigrationName($name)
    {
        $filename = sprintf('%s_create_%s_table.php', date('Y_m_d_His'), strtolower($name));

        return Helpers::postFixWith($filename, '.php');
    }
69277
public function getClassPath($name)
    {
        $name = $this->_formatName($name);
        if ($this->_useStaticRegistry
            && !empty(self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name])
        ) {
            return self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name];
        } elseif (!empty($this->_loadedPluginPaths[$name])) {
            return $this->_loadedPluginPaths[$name];
        }

        if ($this->isLoaded($name)) {
            $class = $this->getClassName($name);
            $r     = new ReflectionClass($class);
            $path  = $r->getFileName();
            if ($this->_useStaticRegistry) {
                self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name] = $path;
            } else {
                $this->_loadedPluginPaths[$name] = $path;
            }
            return $path;
        }

        return false;
    }
932549
public static function getModelClass($name)
    {
        // If the name contains a backslash it is already fully qualified. However in some cases
        // a model might be replaced by a new class and so we must first look to see if this model is
        // mapped and if so return it's replacement instead.
        if (stripos($name, "\\") !== false) {
            $newName = self::getModelNameFromClass($name);

            if ($newName === null) {
                // $name hasn't been registered as a model object. Play safe and return the
                // same class name passed to us.
                return '\\' . ltrim($name, '\\');
            }

            $name = $newName;
        }

        if (self::$modelClassesCache == null) {
            self::$modelClassesCache = [];

            $schemas = self::getAllSchemas();

            self::$modelNamesCache = [];

            foreach ($schemas as $schema) {
                self::$modelClassesCache = array_merge(self::$modelClassesCache, $schema->models);
                self::$modelNamesCache = array_merge(self::$modelNamesCache, $schema->modelClassNames);
            }
        }

        if (isset(self::$modelClassesCache[$name])) {
            return '\\' . ltrim(self::$modelClassesCache[$name], '\\');
        }

        return null;
    }
645484
public function quessByName(string $name)
    {
        return $this->first(function(ExtensionContract $extension) use($name) {
            $package = $extension->getPackageName();

            return (str_contains($package, 'module-')) ? $package === 'module-' . $name : $package === 'component-' . $name;
        });
    }
1181446
protected function _interClassName($name)
    {
        $definition = null;
        if (isset($this->_definitions[$name])) {
            $definition = $this->_definitions[$name];
        } elseif (strpos($name, '\\') !== false) {
            $definition = $name;
        } elseif ($pos = strrpos($name, '_')) {
            $maybe = substr($name, $pos + 1);
            if (isset($this->_definitions[$maybe])) {
                $definition = $this->_definitions[$maybe];
            }
        } elseif (preg_match('#^(.+)([A-Z].+?)$#', $name, $match)) {
            $maybe = lcfirst($match[2]);
            if (isset($this->_definitions[$maybe])) {
                $definition = $this->_definitions[$maybe];
            } else {
                $definition = $this->_getPatterned($name);
            }
        }

        if ($definition === null) {
            throw new InvalidValueException(['`:definition` definition is invalid: missing class field', 'definition' => $name]);
        }

        return is_string($definition) ? $definition : $definition['class'];
    }
1128637
protected function getCacheFilename($name)
    {
        $class = substr($this->generateClassName($name), strlen(static::CLASS_PREFIX));

        return str_replace(
            '/',
            DIRECTORY_SEPARATOR,
            sprintf(
                '%s/%s/%s/%s.php',
                $this->getCacheDir(),
                substr($class, 0, 2),
                substr($class, 2, 2),
                substr($class, 4)
            )
        );
    }
1104908
public static function fqcn(string $name): string
    {
        $type = str_replace('[]', '', $name);

        if (class_exists($type) || interface_exists($type) && '\\' !== $type[0]) {
            return '\\' . $name;
        }

        return $name;
    }
1038065
private function findAlias(Name $name)
    {
        $that = \strtolower($name);
        foreach ($this->aliases as $alias => $prefix) {
            if ($that === $alias) {
                return new FullyQualifiedName($prefix->toString());
            } elseif (\substr($that, 0, \strlen($alias) + 1) === $alias . '\\') {
                return new FullyQualifiedName($prefix->toString() . \substr($name, \strlen($alias)));
            }
        }
    }
797691
public static function get_filename( $name = '' ) {
		$name = str_replace( '.svg', '', $name );
		$filename = dirname( dirname( __DIR__ ) ) . "/svg/$name.svg";

		if ( file_exists( $filename ) ) {
			return $filename;
		}

		return '';
	}
541844
public static function getClassNameWithNS($defaultNS, $name) {
		if (\strpos ( $name, "\\" ) === false) {
			$name = $defaultNS . "\\" . $name;
		}
		return $name;
	}
503435
public function findByName(string $name)
    {
        return $this->first(function(ExtensionContract $extension) use($name) {
            return $extension->getPackage()->getName() === $name;
        });
    }