PHPComposter\PHPComposter\Installer::getSuffix PHP Method

getSuffix() protected method

Get the package name suffix.
Since: 0.1.0
protected getSuffix ( Composer\Package\PackageInterface $package ) : string
$package Composer\Package\PackageInterface Package to inspect.
return string Suffix of the package name.
    protected function getSuffix(PackageInterface $package)
    {
        $result = (array) explode('/', $package->getPrettyName());
        if (count($result) !== 2) {
            throw new InvalidArgumentException(sprintf(_('Unable to install PHP Composter action, could ' . 'not extract action name from package "%1$s"'), $package->getPrettyName()));
        }
        list($vendor, $name) = $result;
        $prefixLength = mb_strlen(self::PREFIX);
        $prefix = mb_substr($name, 0, $prefixLength);
        if (self::PREFIX !== $prefix) {
            throw new InvalidArgumentException(sprintf(_('Unable to install PHP Composter action, actions ' . 'should always start their package name with ' . '"<vendor>/%1$s"'), self::PREFIX));
        }
        return mb_substr($name, $prefixLength);
    }