diff --git a/README.md b/README.md index b4c78e65..ace984a7 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ all vendor code in the vendor directory, and not requiring custom installer code | majima | `majima-plugin` | Mako | `mako-package` | MantisBT | `mantisbt-plugin` +| Matomo | `matomo-plugin` | Mautic | `mautic-core`
`mautic-plugin`
`mautic-theme` | Maya | `maya-module` | MODX | `modx-extra` diff --git a/composer.json b/composer.json index 97831126..5745d3bc 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ "majima", "Mako", "MantisBT", + "Matomo", "Mautic", "Maya", "MODX", diff --git a/src/Composer/Installers/Installer.php b/src/Composer/Installers/Installer.php index 6ebaabae..67a73e9d 100644 --- a/src/Composer/Installers/Installer.php +++ b/src/Composer/Installers/Installer.php @@ -64,6 +64,7 @@ class Installer extends LibraryInstaller 'majima' => 'MajimaInstaller', 'mantisbt' => 'MantisBTInstaller', 'mako' => 'MakoInstaller', + 'matomo' => 'MatomoInstaller', 'maya' => 'MayaInstaller', 'mautic' => 'MauticInstaller', 'mediawiki' => 'MediaWikiInstaller', diff --git a/src/Composer/Installers/MatomoInstaller.php b/src/Composer/Installers/MatomoInstaller.php new file mode 100644 index 00000000..57fdb033 --- /dev/null +++ b/src/Composer/Installers/MatomoInstaller.php @@ -0,0 +1,28 @@ + */ + protected $locations = array( + 'plugin' => 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars(array $vars): array + { + $vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/tests/Composer/Installers/Test/InstallerTest.php b/tests/Composer/Installers/Test/InstallerTest.php index 01abf369..1345c8fd 100644 --- a/tests/Composer/Installers/Test/InstallerTest.php +++ b/tests/Composer/Installers/Test/InstallerTest.php @@ -150,6 +150,7 @@ public function supportsProvider(): array array('magento-library', true), array('majima-plugin', true), array('mako-package', true), + array('matomo-plugin', true), array('mantisbt-plugin', true), array('miaoxing-plugin', true), array('modx-extra', true), @@ -351,6 +352,7 @@ public function installPathProvider(): array array('modxevo-lib', 'assets/lib/my_lib/', 'shama/my_lib'), array('mako-package', 'app/packages/my_package/', 'shama/my_package'), array('mantisbt-plugin', 'plugins/MyPlugin/', 'shama/my_plugin'), + array('matomo-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'), array('mediawiki-extension', 'extensions/APC/', 'author/APC'), array('mediawiki-extension', 'extensions/APC/', 'author/APC-extension'), array('mediawiki-extension', 'extensions/UploadWizard/', 'author/upload-wizard'), diff --git a/tests/Composer/Installers/Test/MatomoInstallerTest.php b/tests/Composer/Installers/Test/MatomoInstallerTest.php new file mode 100644 index 00000000..d8287d72 --- /dev/null +++ b/tests/Composer/Installers/Test/MatomoInstallerTest.php @@ -0,0 +1,47 @@ +package = new Package('VisitSummary', '1.0', '1.0'); + $this->composer = new Composer(); + } + + public function testInflectPackageVars(): void + { + $installer = new MatomoInstaller($this->package, $this->composer, $this->getMockIO()); + $result = $installer->inflectPackageVars(array('name' => 'VisitSummary')); + $this->assertEquals($result, array('name' => 'VisitSummary')); + + $installer = new MatomoInstaller($this->package, $this->composer, $this->getMockIO()); + $result = $installer->inflectPackageVars(array('name' => 'visit-summary')); + $this->assertEquals($result, array('name' => 'VisitSummary')); + + $installer = new MatomoInstaller($this->package, $this->composer, $this->getMockIO()); + $result = $installer->inflectPackageVars(array('name' => 'visit_summary')); + $this->assertEquals($result, array('name' => 'VisitSummary')); + } +}