--plugins
option:
phpmetrics --plugins=plugin1.php,plugin2.php <sources>
Offical plugins:
First, you need to create the main class. This class must implements Hal\Application\Extension\Extension
. Remember to return a new instance of your class in your file.
Create the ./MyPlugin/MyPlugin.php
file:
<?php
namespace My;
use Hal\Application\Config\Configuration;
use Hal\Application\Extension\Extension;
use Hal\Application\Extension\Reporter;
use Hal\Application\Extension\ReporterHtmlSummary;
use Hal\Component\Bounds\Bounds;
use Hal\Component\Result\ResultCollection;
require_once __DIR__.'/HtmlRenderer.php';
class MyExtension implements Extension {
/**
* @inheritdoc
*/
public function receive(Configuration $configuration, ResultCollection $collection, ResultCollection $aggregatedResults, Bounds $bounds)
{
// nothing to do here
}
/**
* @inheritdoc
*/
public function getName()
{
return 'my nice extension';
}
/**
* @inheritdoc
*/
public function getReporterHtmlSummary()
{
return new HtmlRenderer;
}
/**
* @inheritdoc
*/
public function getReporterCliSummary()
{
// if you don't need to add anything in CLI report, just return 'null'
return null;
}
}
return new MyExtension;
Now you just need to develop the renderer for HTML, in the ./MyPlugin/HtmlRenderer.php
file.
<?php
namespace My;
use Hal\Application\Extension\Reporter\ReporterHtmlSummary;
class HtmlRenderer implements ReporterHtmlSummary {
/**
* @inheritdoc
*/
public function getMenus()
{
// you can add one or more items to the menu
return [
'myplugin' => 'Label displayed in the menu'
];
}
/**
* @inheritdoc
*/
public function renderJs()
{
// add your Js code here
return "document.getElementById('link-myplugin').onclick = function() { displayTab(this, 'myplugin')};";
}
/**
* @inheritdoc
*/
public function renderHtml()
{
return <<<EOT
<div class="tab" id="myplugin">
<div class="row">
<h3>My nice plugin</h3>
<p>
Just change the content here.
</p>
</div>
EOT;
}
}