-
-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #514 from codymorgan/main
added matomo-plugin
- Loading branch information
Showing
6 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
"majima", | ||
"Mako", | ||
"MantisBT", | ||
"Matomo", | ||
"Mautic", | ||
"Maya", | ||
"MODX", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Composer\Installers; | ||
|
||
/** | ||
* Class MatomoInstaller | ||
* | ||
* @package Composer\Installers | ||
*/ | ||
class MatomoInstaller extends BaseInstaller | ||
{ | ||
/** @var array<string, string> */ | ||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Composer\Installers\Test; | ||
|
||
use Composer\Composer; | ||
use Composer\Installers\MatomoInstaller; | ||
use Composer\Package\Package; | ||
use Composer\Package\PackageInterface; | ||
|
||
/** | ||
* Class MatomoInstallerTest | ||
* | ||
* @package Composer\Installers\Test | ||
*/ | ||
class MatomoInstallerTest extends TestCase | ||
{ | ||
/** | ||
* @var Composer | ||
*/ | ||
private $composer; | ||
|
||
/** | ||
* @var Package | ||
*/ | ||
private $package; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->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')); | ||
} | ||
} |