Get the module name

@param PackageInterface $package
@return string
487497
protected function getModuleName(PackageInterface $package)
    {
        $extra = $package->getExtra();

        if (isset($extra['modulename'])) {
            $name = $extra['modulename'];
        } else {
            $name = strtr($package->getPrettyName(), array(
                '\\' => '.',
                '-' => '.',
                '_' => '.',
                ' ' => ''
            ));
        }

        return $name;
    }
1203067
protected function getInstallerConfig(PackageInterface $package)
    {
        if ($this->installerConfig !== null) {
            return $this->installerConfig;
        }

        $type       = $package->getType();
        $prettyName = $package->getPrettyName();

        if (strpos($prettyName, '/') !== false) {
            list($vendor, $name) = explode('/', $prettyName);
        } else {
            $vendor = '';
            $name   = $prettyName;
        }

        $extra = $package->getExtra();

        if (!empty($extra['installer-name'])) {
            $name = $extra['installer-name'];
        }

        $loader = 'mu-plugins/' . $name . '.php';

        if (!empty($extra['installer-loader'])) {
            $loader = $extra['installer-loader'];
        }

        return compact('name', 'vendor', 'type', 'loader');
    }
599239
public function processPackage(PackageInterface $package)
    {
        $extra = $package->getExtra();
        $files = isset($extra[self::EXTRA_OPTION_NAME]) ? $extra[self::EXTRA_OPTION_NAME] : null;
        if ($package->getType() !== self::PACKAGE_TYPE && is_null($files)) {
            return;
        }

        $extension = [
            'name'    => $package->getName(),
            'version' => $package->getVersion(),
        ];
        if ($package->getVersion() === '9999999-dev') {
            $reference = $package->getSourceReference() ?: $package->getDistReference();
            if ($reference) {
                $extension['reference'] = $reference;
            }
        }
        $this->data['extensions'][$package->getName()] = $extension;

        $aliases = array_merge(
            $this->prepareAliases($package, 'psr-0'),
            $this->prepareAliases($package, 'psr-4')
        );
        $this->data['aliases'] = array_merge($this->data['aliases'], $aliases);
        foreach ((array) $files as $name => $path) {
            $config = $this->readExtensionConfig($package, $path);
            $config['aliases'] = array_merge(
                $aliases,
                isset($config['aliases']) ? (array) $config['aliases'] : []
            );
            $this->data['aliases'] = array_merge($this->data['aliases'], $config['aliases']);
            $this->data[$name] = isset($this->data[$name]) ? Helper::mergeConfig($this->data[$name], $config) : $config;
        }
    }
45660
public function getRequiredVersion(RootPackageInterface $package)
    {
        foreach (array($package->getRequires(), $package->getDevRequires()) as $requiredPackages) {
            if (isset($requiredPackages[static::PACKAGE_NAME])) {
                return $requiredPackages[static::PACKAGE_NAME]->getPrettyConstraint();
            }
        }
        throw new \RuntimeException('Can not determine required version of ' . static::PACKAGE_NAME);
    }
186432
public function isPackageInstalled(PackageInterface $package)
    {
        return $this->filesystem->exists($this->config->getInstallDir() . '/' . $package->getName() . '/.bower.json');
    }
93826
protected function _removeAutoloader(PackageInterface $package)
    {
        $path = $this->_getAutoloaderPath($package);

        if(file_exists($path))
        {
            $contents = file_get_contents($path);

            if (strpos($contents, 'This file has been generated automatically by Composer.') !== false) {
                unlink($path);
            }
        }
    }
968599
public function isForPackage(PackageInterface $package)
    {
        if ($this->getForPackage() !== $package->getName()) {
            return false;
        }
        $fpv = $this->getForPackageVersion();
        if ($fpv !== null) {
            $pv = new Constraint('=', $package->getVersion());
            if (!$fpv->matches($pv)) {
                return false;
            }
        }

        return true;
    }
504290
protected function normalizeBranchAlias(PackageInterface $package)
    {
        $stability = VersionParser::parseStability($this->versionParser->normalize($this->rootPackageVersion));
        $aliasNormalized = 'dev-'.$this->rootPackageVersion;

        if (BasePackage::STABILITY_STABLE === BasePackage::$stabilities[$stability]
            && null === $this->findPackage($package->getName(), $this->rootPackageVersion)) {
            $aliasNormalized = $this->versionParser->normalize($this->rootPackageVersion);
        }

        return $aliasNormalized;
    }
677453
public function getAlias($package)
    {
        if (is_string($package)) {
            $package = ltrim(StringNormalise::toClassNamespace($package), '\\');
        } elseif (is_object($package)) {
            $package = get_class($package);
        } else {
            throw new \InvalidArgumentException('Please send package object or class name.');
        }

        if (isset($this->aliases[$package])) {
            return $this->aliases[$package];
        }

        return null;
    }
697031
public function resolveName($package)
	{
		if (is_object($package)) {
			$package = get_class($package);
		}

		$package = substr($package, strrpos($package, '\\'));

		$package = trim($package, '\\');

		$package = str_replace(array('Supra', 'Package'), '', $package);

		return $package;
	}
559820
public function updatePackage(PackageInterface $package, InstallerInterface $installer)
    {
        if (!$this->isPackageInstalled($package)) {
            throw new RuntimeException(sprintf('Package %s is not installed.', $package->getName()));
        }
        if (is_null($package->getRequiredVersion())) {
            $decode = $this->config->getBowerFileContent();
            if (empty($decode['dependencies']) || empty($decode['dependencies'][$package->getName()])) {
                throw new InvalidArgumentException(sprintf('Package %s not found in bower.json', $package->getName()));
            }
            $package->setRequiredVersion($decode['dependencies'][$package->getName()]);
        }

        $bower = $this->config->getPackageBowerFileContent($package);
        $package->setInfo($bower);
        $package->setVersion($bower['version']);
        $package->setRequires(isset($bower['dependencies']) ? $bower['dependencies'] : null);

        $packageTag = $this->getPackageTag($package);
        $this->output->writelnInfoPackage($package, 'validate', sprintf('%s against %s#%s', $packageTag, $package->getName(), $package->getRequiredVersion()));

        $package->setRepository($this->repository);
        if ($packageTag == $package->getVersion()) {
            // if version is fully matching, there's no need to update
            return;
        }
        $package->setVersion($packageTag);

        $this->cachePackage($package);

        $this->output->writelnUpdatingPackage($package);
        $installer->update($package);

        $overrides = $this->config->getOverrideFor($package->getName());
        if (array_key_exists('dependencies', $overrides)) {
            $dependencies = $overrides['dependencies'];
        } else {
            $dependencies = $package->getRequires();
        }
        if (!empty($dependencies)) {
            foreach ($dependencies as $name => $requiredVersion) {
                $depPackage = new Package($name, $requiredVersion);
                if (!$this->isPackageInstalled($depPackage)) {
                    $this->installPackage($depPackage, $installer, true);
                } elseif ($this->isNeedUpdate($depPackage)) {
                    $this->updatePackage($depPackage, $installer);
                }
            }
        }
    }
1336044
protected function getSymlinkSourcePath(PackageInterface $package)
    {
        if (null != $this->config->getSymlinkBasePath()) {
            $targetDir = $package->getTargetDir();
            $sourcePath =
                $this->config->getSymlinkBasePath()
                . '/' . $package->getPrettyName()
                . '/' . $package->getPrettyVersion()
                . ($targetDir ? '/' . $targetDir : '')
            ;
        } else {
            $sourcePath = $this->getInstallPath($package);
        }

        return $sourcePath;
    }
890536
protected function loadInits(PackageInterface $package)
    {
        if (!$package->getInits()) {
            return $this;
        }

        $initLoader = \Parable\DI\Container::create(\Parable\Framework\Loader\InitLoader::class);
        $initLoader->load($package->getInits());
        return $this;
    }
1058886
public function unlockPackage(PackageInterface $package)
    {
        $name = $package->getPrettyName();
        $lock = 'extra/tenside/version-locks/' . $this->escape($name);

        // Nothing to do?
        if (!$this->has($lock)) {
            return $this;
        }

        if (false === ($constraint = $this->get($lock))) {
            $this->remove($lock);
            $this->requirePackage($name, null);
            $this->cleanEmptyArraysInPath('extra/tenside');

            return $this;
        }

        $this->requirePackage($name, $constraint);
        $this->remove($lock);
        $this->cleanEmptyArraysInPath('extra/tenside');

        return $this;
    }
125297
private function getContaoExtra(PackageInterface $package, $key)
    {
        $extras = $package->getExtra();

        if (!isset($extras['contao']) || !isset($extras['contao'][$key])) {
            return null;
        }

        return $extras['contao'][$key];
    }
1327094
public function getPatchesFor(PackageInterface $package)
    {
        $patches = array();
        foreach ($this->getPatches() as $patch) {
            if ($patch->isForPackage($package)) {
                $patches[] = $patch;
            }
        }
        $result = new static();
        $result->patches = $patches;

        return $result;
    }
404807
public function parse(PackageInterface $package)
    {
        $extraFiles = [];
        $extra = $package->getExtra();
        if (!empty($extra['extra-files'])) {
            foreach ((array) $extra['extra-files'] as $id => $extraFile) {
                $file = new ExtraFile(
                    $package,
                    $id,
                    $extraFile['url'],
                    $this->parseDistType($extraFile['url']),
                    $extraFile['path']
                );
                $extraFiles[] = $file;
            }
        }

        return $extraFiles;
    }