# code-snippets/trunk/vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php

Code Snippets, version trunk. 56 lines.

- Page: https://pluginprobe.com/plugins/code-snippets/trunk/code/vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php
- Raw: https://pluginprobe.com/plugins/code-snippets/trunk/raw/vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php
- Modified: 2025-02-14T05:52:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/code-snippets/trunk/code/vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php#L10-L20`.

```php
<?php

namespace Composer\Installers;

class SyDESInstaller extends BaseInstaller
{
    /** @var array<string, string> */
    protected $locations = array(
        'module' => 'app/modules/{$name}/',
        'theme'  => 'themes/{$name}/',
    );

    /**
     * Format module name.
     *
     * Strip `sydes-` prefix and a trailing '-theme' or '-module' from package name if present.
     */
    public function inflectPackageVars(array $vars): array
    {
        if ($vars['type'] == 'sydes-module') {
            return $this->inflectModuleVars($vars);
        }

        if ($vars['type'] === 'sydes-theme') {
            return $this->inflectThemeVars($vars);
        }

        return $vars;
    }

    /**
     * @param array<string, string> $vars
     * @return array<string, string>
     */
    public function inflectModuleVars(array $vars): array
    {
        $vars['name'] = $this->pregReplace('/(^sydes-|-module$)/i', '', $vars['name']);
        $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
        $vars['name'] = str_replace(' ', '', ucwords($vars['name']));

        return $vars;
    }

    /**
     * @param array<string, string> $vars
     * @return array<string, string>
     */
    protected function inflectThemeVars(array $vars): array
    {
        $vars['name'] = $this->pregReplace('/(^sydes-|-theme$)/', '', $vars['name']);
        $vars['name'] = strtolower($vars['name']);

        return $vars;
    }
}

```
