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 / MajimaInstaller.php

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

47 lines 1.1 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 /**
6 * Plugin/theme installer for majima
7 * @author David Neustadt
8 */
9 class MajimaInstaller extends BaseInstaller
10 {
11 /** @var array<string, string> */
12 protected $locations = array(
13 'plugin' => 'plugins/{$name}/',
14 );
15
16 /**
17 * Transforms the names
18 *
19 * @param array<string, string> $vars
20 * @return array<string, string>
21 */
22 public function inflectPackageVars(array $vars): array
23 {
24 return $this->correctPluginName($vars);
25 }
26
27 /**
28 * Change hyphenated names to camelcase
29 *
30 * @param array<string, string> $vars
31 * @return array<string, string>
32 */
33 private function correctPluginName(array $vars): array
34 {
35 $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) {
36 return strtoupper($matches[0][1]);
37 }, $vars['name']);
38
39 if (null === $camelCasedName) {
40 throw new \RuntimeException('Failed to run preg_replace_callback: '.preg_last_error());
41 }
42
43 $vars['name'] = ucfirst($camelCasedName);
44 return $vars;
45 }
46 }
47