PluginProbe
Code Snippets / 4.0.0-beta.2
Code Snippets v4.0.0-beta.2
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / vendor / composer / installers / src / Composer / Installers / SyDESInstaller.php

SyDESInstaller.php in Code Snippets 4.0.0-beta.2, at vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php

56 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Composer\Installers;
4
5 class SyDESInstaller extends BaseInstaller
6 {
7 /** @var array<string, string> */
8 protected $locations = array(
9 'module' => 'app/modules/{$name}/',
10 'theme' => 'themes/{$name}/',
11 );
12
13 /**
14 * Format module name.
15 *
16 * Strip `sydes-` prefix and a trailing '-theme' or '-module' from package name if present.
17 */
18 public function inflectPackageVars(array $vars): array
19 {
20 if ($vars['type'] == 'sydes-module') {
21 return $this->inflectModuleVars($vars);
22 }
23
24 if ($vars['type'] === 'sydes-theme') {
25 return $this->inflectThemeVars($vars);
26 }
27
28 return $vars;
29 }
30
31 /**
32 * @param array<string, string> $vars
33 * @return array<string, string>
34 */
35 public function inflectModuleVars(array $vars): array
36 {
37 $vars['name'] = $this->pregReplace('/(^sydes-|-module$)/i', '', $vars['name']);
38 $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
39 $vars['name'] = str_replace(' ', '', ucwords($vars['name']));
40
41 return $vars;
42 }
43
44 /**
45 * @param array<string, string> $vars
46 * @return array<string, string>
47 */
48 protected function inflectThemeVars(array $vars): array
49 {
50 $vars['name'] = $this->pregReplace('/(^sydes-|-theme$)/', '', $vars['name']);
51 $vars['name'] = strtolower($vars['name']);
52
53 return $vars;
54 }
55 }
56