PluginProbe
Code Snippets / 3.10.1
Code Snippets v3.10.1
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 / TastyIgniterInstaller.php

TastyIgniterInstaller.php in Code Snippets 3.10.1, at vendor/composer/installers/src/Composer/Installers/TastyIgniterInstaller.php

86 lines 2.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 TastyIgniterInstaller extends BaseInstaller
6 {
7 /** @var array<string, string> */
8 protected $locations = [
9 'module' => 'app/{$name}/',
10 'extension' => 'extensions/{$vendor}/{$name}/',
11 'theme' => 'themes/{$name}/',
12 ];
13
14 /**
15 * Format package name.
16 *
17 * Cut off leading 'ti-ext-' or 'ti-theme-' if present.
18 * Strip vendor name of characters that is not alphanumeric or an underscore
19 *
20 */
21 public function inflectPackageVars(array $vars): array
22 {
23 $extra = $this->package->getExtra();
24
25 if ($vars['type'] === 'tastyigniter-module') {
26 return $this->inflectModuleVars($vars);
27 }
28
29 if ($vars['type'] === 'tastyigniter-extension') {
30 return $this->inflectExtensionVars($vars, $extra);
31 }
32
33 if ($vars['type'] === 'tastyigniter-theme') {
34 return $this->inflectThemeVars($vars, $extra);
35 }
36
37 return $vars;
38 }
39
40 /**
41 * @param array<string, string> $vars
42 * @return array<string, string>
43 */
44 protected function inflectModuleVars(array $vars): array
45 {
46 $vars['name'] = $this->pregReplace('/^ti-module-/', '', $vars['name']);
47
48 return $vars;
49 }
50
51 /**
52 * @param array<string, string> $vars
53 * @param array<string, mixed> $extra
54 * @return array<string, string>
55 */
56 protected function inflectExtensionVars(array $vars, array $extra): array
57 {
58 if (!empty($extra['tastyigniter-extension']['code'])) {
59 $parts = explode('.', $extra['tastyigniter-extension']['code']);
60 $vars['vendor'] = (string)$parts[0];
61 $vars['name'] = (string)($parts[1] ?? '');
62 }
63
64 $vars['vendor'] = $this->pregReplace('/[^a-z0-9_]/i', '', $vars['vendor']);
65 $vars['name'] = $this->pregReplace('/^ti-ext-/', '', $vars['name']);
66
67 return $vars;
68 }
69
70 /**
71 * @param array<string, string> $vars
72 * @param array<string, mixed> $extra
73 * @return array<string, string>
74 */
75 protected function inflectThemeVars(array $vars, array $extra): array
76 {
77 if (!empty($extra['tastyigniter-theme']['code'])) {
78 $vars['name'] = $extra['tastyigniter-theme']['code'];
79 }
80
81 $vars['name'] = $this->pregReplace('/^ti-theme-/', '', $vars['name']);
82
83 return $vars;
84 }
85 }
86