Skip to content

Commit c29dc4b

Browse files
authored
Merge pull request #514 from codymorgan/main
added matomo-plugin
2 parents af93ba6 + 722a5e3 commit c29dc4b

File tree

6 files changed

+80
-0
lines changed

6 files changed

+80
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ all vendor code in the vendor directory, and not requiring custom installer code
8080
| majima | `majima-plugin`
8181
| Mako | `mako-package`
8282
| MantisBT | `mantisbt-plugin`
83+
| Matomo | `matomo-plugin`
8384
| Mautic | `mautic-core`<br>`mautic-plugin`<br>`mautic-theme`
8485
| Maya | `maya-module`
8586
| MODX | `modx-extra`

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"majima",
3939
"Mako",
4040
"MantisBT",
41+
"Matomo",
4142
"Mautic",
4243
"Maya",
4344
"MODX",

src/Composer/Installers/Installer.php

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class Installer extends LibraryInstaller
6464
'majima' => 'MajimaInstaller',
6565
'mantisbt' => 'MantisBTInstaller',
6666
'mako' => 'MakoInstaller',
67+
'matomo' => 'MatomoInstaller',
6768
'maya' => 'MayaInstaller',
6869
'mautic' => 'MauticInstaller',
6970
'mediawiki' => 'MediaWikiInstaller',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Composer\Installers;
4+
5+
/**
6+
* Class MatomoInstaller
7+
*
8+
* @package Composer\Installers
9+
*/
10+
class MatomoInstaller extends BaseInstaller
11+
{
12+
/** @var array<string, string> */
13+
protected $locations = array(
14+
'plugin' => 'plugins/{$name}/',
15+
);
16+
17+
/**
18+
* Format package name to CamelCase
19+
*/
20+
public function inflectPackageVars(array $vars): array
21+
{
22+
$vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
23+
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
24+
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
25+
26+
return $vars;
27+
}
28+
}

tests/Composer/Installers/Test/InstallerTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ public function supportsProvider(): array
150150
array('magento-library', true),
151151
array('majima-plugin', true),
152152
array('mako-package', true),
153+
array('matomo-plugin', true),
153154
array('mantisbt-plugin', true),
154155
array('miaoxing-plugin', true),
155156
array('modx-extra', true),
@@ -351,6 +352,7 @@ public function installPathProvider(): array
351352
array('modxevo-lib', 'assets/lib/my_lib/', 'shama/my_lib'),
352353
array('mako-package', 'app/packages/my_package/', 'shama/my_package'),
353354
array('mantisbt-plugin', 'plugins/MyPlugin/', 'shama/my_plugin'),
355+
array('matomo-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'),
354356
array('mediawiki-extension', 'extensions/APC/', 'author/APC'),
355357
array('mediawiki-extension', 'extensions/APC/', 'author/APC-extension'),
356358
array('mediawiki-extension', 'extensions/UploadWizard/', 'author/upload-wizard'),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace Composer\Installers\Test;
4+
5+
use Composer\Composer;
6+
use Composer\Installers\MatomoInstaller;
7+
use Composer\Package\Package;
8+
use Composer\Package\PackageInterface;
9+
10+
/**
11+
* Class MatomoInstallerTest
12+
*
13+
* @package Composer\Installers\Test
14+
*/
15+
class MatomoInstallerTest extends TestCase
16+
{
17+
/**
18+
* @var Composer
19+
*/
20+
private $composer;
21+
22+
/**
23+
* @var Package
24+
*/
25+
private $package;
26+
27+
public function setUp(): void
28+
{
29+
$this->package = new Package('VisitSummary', '1.0', '1.0');
30+
$this->composer = new Composer();
31+
}
32+
33+
public function testInflectPackageVars(): void
34+
{
35+
$installer = new MatomoInstaller($this->package, $this->composer, $this->getMockIO());
36+
$result = $installer->inflectPackageVars(array('name' => 'VisitSummary'));
37+
$this->assertEquals($result, array('name' => 'VisitSummary'));
38+
39+
$installer = new MatomoInstaller($this->package, $this->composer, $this->getMockIO());
40+
$result = $installer->inflectPackageVars(array('name' => 'visit-summary'));
41+
$this->assertEquals($result, array('name' => 'VisitSummary'));
42+
43+
$installer = new MatomoInstaller($this->package, $this->composer, $this->getMockIO());
44+
$result = $installer->inflectPackageVars(array('name' => 'visit_summary'));
45+
$this->assertEquals($result, array('name' => 'VisitSummary'));
46+
}
47+
}

0 commit comments

Comments
 (0)