PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / vendor / composer / installers / src / Composer / Installers / SyDESInstaller.php

SyDESInstaller.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF trunk, 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