New data for new plugin
This commit is contained in:
parent
d26e4ee364
commit
787bccda1c
|
@ -15,6 +15,7 @@ use PHPCI\Model\Build;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Loc - Allows PHP Copy / Lines of Code testing.
|
* PHP Loc - Allows PHP Copy / Lines of Code testing.
|
||||||
|
*
|
||||||
* @author Johan van der Heide <info@japaveh.nl>
|
* @author Johan van der Heide <info@japaveh.nl>
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
|
@ -30,11 +31,18 @@ class PhpLoc implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||||
*/
|
*/
|
||||||
protected $phpci;
|
protected $phpci;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Build
|
||||||
|
*/
|
||||||
|
protected $build;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this plugin can be executed.
|
* Check if this plugin can be executed.
|
||||||
* @param $stage
|
*
|
||||||
|
* @param $stage
|
||||||
* @param Builder $builder
|
* @param Builder $builder
|
||||||
* @param Build $build
|
* @param Build $build
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function canExecute($stage, Builder $builder, Build $build)
|
public static function canExecute($stage, Builder $builder, Build $build)
|
||||||
|
@ -48,14 +56,15 @@ class PhpLoc implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* Set up the plugin, configure options, etc.
|
||||||
|
*
|
||||||
* @param Builder $phpci
|
* @param Builder $phpci
|
||||||
* @param Build $build
|
* @param Build $build
|
||||||
* @param array $options
|
* @param array $options
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = array())
|
public function __construct(Builder $phpci, Build $build, array $options = array())
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
$this->phpci = $phpci;
|
||||||
$this->build = $build;
|
$this->build = $build;
|
||||||
$this->directory = $phpci->buildPath;
|
$this->directory = $phpci->buildPath;
|
||||||
|
|
||||||
if (isset($options['directory'])) {
|
if (isset($options['directory'])) {
|
||||||
|
@ -82,17 +91,30 @@ class PhpLoc implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||||
$phploc = $this->phpci->findBinary('phploc');
|
$phploc = $this->phpci->findBinary('phploc');
|
||||||
|
|
||||||
$success = $this->phpci->executeCommand($phploc . ' %s "%s"', $ignore, $this->directory);
|
$success = $this->phpci->executeCommand($phploc . ' %s "%s"', $ignore, $this->directory);
|
||||||
$output = $this->phpci->getLastOutput();
|
$output = $this->phpci->getLastOutput();
|
||||||
|
|
||||||
if (preg_match_all('/\((LOC|CLOC|NCLOC|LLOC)\)\s+([0-9]+)/', $output, $matches)) {
|
if (preg_match_all('/\((LOC|CLOC|NCLOC|LLOC)\)\s+([0-9]+)/', $output, $matches2)) {
|
||||||
$data = array();
|
$data = array();
|
||||||
foreach ($matches[1] as $k => $v) {
|
foreach ($matches2[1] as $k => $v) {
|
||||||
$data[$v] = (int)$matches[2][$k];
|
$data[$v] = (int) $matches2[2][$k];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->build->storeMeta('phploc', $data);
|
$this->build->storeMeta('phploc', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (preg_match_all('/(Namespaces|Interfaces|Classes|Methods)\s+([0-9]+)/', $output, $matches)) {
|
||||||
|
$key = $matches[1];
|
||||||
|
$val = $matches[2];
|
||||||
|
$data = array(
|
||||||
|
$key[1] => (int) $val[1],
|
||||||
|
$key[2] => (int) $val[2],
|
||||||
|
$key[3] => (int) $val[3],
|
||||||
|
$key[6] => (int) $val[6],
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->build->storeMeta('phploc-structure', $data);
|
||||||
|
}
|
||||||
|
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue