PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.3.2
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.3.2
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 / MajimaInstaller.php

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