@param string $package

@return string
972622
protected static function getVersionForPackage(string $package): string
    {
        try {
            $shortVersion = PrettyVersions::getVersion($package)
                ->getShortVersion()
            ;

            // Removes the ".x-dev" part which is inserted during development
            if ('.x-dev' === \mb_substr($shortVersion, -6)) {
                $shortVersion = \mb_substr($shortVersion, 0, -6).'-dev';
            }

            return $shortVersion;
        } catch (\OutOfBoundsException $exception) {
            return '0.0.0-alpha';
        }
    }
768342
protected function getProviderStub(Package $package, $plain)
	{
		return $this->formatPackageStub($package, $this->getProviderFile($plain));
	}
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;
    }
227227
protected function checkGitignore($package)
    {
        $gitFolder = getcwd() . DS . '.git' . DS;

        if (!file_exists($gitFolder)) {
            return;
        }

        $gitignoreFile = getcwd() . DS . '.gitignore';
        $required = [
            '/.vagrant/',
            '/puphpet/files/dot/',
            '/puphpet/puppet/',
            '/puphpet/ruby/',
            '/puphpet/shell/',
            '/puphpet/vagrant/',
            '/puphpet/config-custom.yaml',
            '/Vagrantfile',
        ];

        touch($gitignoreFile);
        $lines = file($gitignoreFile, FILE_IGNORE_NEW_LINES);

        foreach ($required as $entry) {
            if (!in_array($entry, $lines, true)) {
                $lines[] = $entry;
            }
        }

        file_put_contents($gitignoreFile, implode(PHP_EOL, $lines) . PHP_EOL);
    }
1234173
private function getOrCreate($package)
    {
        if (isset($this->packages[strtolower($package)])) {
            return $this->packages[strtolower($package)];
        }

        return $this->packages[strtolower($package)] = new PackageNode($package);
    }
783683
public function prependPackage($package) {
		$package = $this->handlePackage($package);
		
		$this->packages->unshift($package);
		return $package;
	}
1209382
public static function get_version($package = 'project') {
		if (Config::$version_storage == 'file') {
			return self::file_get_version($package);
		} elseif (Config::$version_storage == 'database') {
			return self::database_get_version($package);
		} else {
			throw new \Exception('Incorrect "version_storage" config setting');
		}
	}
218368
public function subscribeTo($package)
    {
        if (!$this->hasSubscription(false)) {
            $this->_mixer->subscription = $this->getService('repos:subscriptions.subscription')
            ->getEntity(array(
                'data' => array(
                    'package' => $package,
                  ),
            ));
            $this->_mixer->verified = 1;
        }

        return $this->_mixer->subscription;
    }
248605
protected function chooseVersion(Package $package)
    {
        $versions = $package->getVersions();

        if (count($versions) === 1) {
            $v = current($versions)->getVersion();
            $this->comment('Version to install: ' . $v);
            return $v;
        }

        $default = 1;
        $latest = $this->getLatestStable($package);
        $i = 1;

        $this->comment('Available versions:');
        foreach ($versions as $version) {
            $v = $version->getVersion();
            $versionsAvailable[$i] = $v;
            if ($v === $latest) {
                $default = $i;
            }

            $this->getOutput()->writeln(sprintf(
                '[%d] <info>%s</info> (%s)',
                $i,
                $v,
                Carbon::parse($version->getTime())->format('Y-m-d H:i:s')
            ));

            ++$i;
        }

        $choose = $this->ask('Select version by number [' . $default . ']:', $default);

        if (!is_numeric($choose) || !isset($versionsAvailable[$choose])) {
            $this->error('Incorrect value given!');
            return $this->chooseVersion($package);
        } else {
            $this->comment('Your choice: ' . $versionsAvailable[$choose]);
            return $versionsAvailable[$choose];
        }
    }
620060
private function packageRegistered($package)
    {
        $package_registered = array_key_exists($package, $this->packages);

        if ($package_registered) {
            $this->updateLog("info", "Package {$package} is registered");
        } else {
            $this->updateLog("info", "Package {$package} is not registered");
        }

        return $package_registered;
    }
1280883
protected function formatPackageStub(Package $package, $stub)
	{
		foreach (get_object_vars($package) as $key => $value)
		{
			$stub = str_replace('{{'.snake_case($key).'}}', $value, $stub);
		}
		
		return $stub;
	}
172970
public function appendPackage($package) {
		$package = $this->handlePackage($package);
		
		$this->packages[] = $package;
		return $package;
	}
1125393
public function getInstallPath(PackageInterface $package): string
    {
        $this->vendorPath = parent::getInstallPath($package);
        return $this->vendorPath;
    }
699615
public function getRegistry($package = null)
    {
        if (isset($package)) {
            if ($this->registered($package)) {
                return $this->registry[ $package ];
            }

            return false;
        }

        return $this->registry;
    }
490467
protected function searchProvides($package)
    {
        $packageName = $package instanceof Package ? $package->getName() : $package;
        $providesJsonLocation = base_path("vendor/{$packageName}/provides.json");
        if (file_exists($providesJsonLocation)) {
            $provides = json_decode(str_replace('\\', '\\\\', file_get_contents($providesJsonLocation)), true);
            $return = array('providers' => array(), 'aliases' => array());
            if (isset($provides['providers']) && is_array($provides['providers'])) {
                $return['providers'] = $provides['providers'];
            }
            if (isset($provides['aliases']) && is_array($provides['aliases'])) {
                $return['aliases'] = $provides['aliases'];
            }
            return $return;
        }
        return false;
    }
1130313
private function getPackageName(PackageInterface $package)
    {
        if (is_array($package->getExtra()) && isset($package->getExtra()['installer-name'])) {
            return $package->getExtra()['installer-name'];
        }

        $name = explode('/', $package->getPrettyName());
        $packageName = $name[1];

        if (count(explode('-', $packageName)) < 2) {
            throw new Exception('Bundle names should be like "vendor/NAME-bundle"');
        }

        $packageName = str_replace('-bundle', '', $packageName);

        return str_replace(' ', '', ucwords(str_replace('-', ' ', $packageName)));
    }
1136654
public static function provider($package)
    {
        $location = __DIR__.'/../../'.$package.'/src';

        $files = is_dir($location) ? scandir($location) : [];

        foreach ($files as $file) {
            if (strpos($file, 'ServiceProvider') !== false) {
                return str_replace('.php', '', $file);
            }
        }

        return false;
    }