2013-05-03 17:02:53 +02:00
|
|
|
<?php
|
2013-05-16 03:16:56 +02:00
|
|
|
/**
|
|
|
|
* PHPCI - Continuous Integration for PHP
|
|
|
|
*
|
|
|
|
* @copyright Copyright 2013, Block 8 Limited.
|
|
|
|
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
|
|
|
|
* @link http://www.phptesting.org/
|
|
|
|
*/
|
2013-05-03 17:02:53 +02:00
|
|
|
|
|
|
|
namespace PHPCI\Plugin;
|
|
|
|
|
2013-05-16 03:30:48 +02:00
|
|
|
/**
|
|
|
|
* PHP Mess Detector Plugin - Allows PHP Mess Detector testing.
|
|
|
|
* @author Dan Cryer <dan@block8.co.uk>
|
|
|
|
* @package PHPCI
|
|
|
|
* @subpackage Plugins
|
|
|
|
*/
|
2013-05-03 17:02:53 +02:00
|
|
|
class PhpMessDetector implements \PHPCI\Plugin
|
|
|
|
{
|
2013-05-16 16:50:19 +02:00
|
|
|
protected $directory;
|
2013-07-19 15:40:16 +02:00
|
|
|
/**
|
|
|
|
* Array of PHPMD rules. Possible values: codesize, unusedcode, naming, design, controversial
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $rules;
|
2013-05-03 17:02:53 +02:00
|
|
|
|
2013-05-16 16:50:19 +02:00
|
|
|
public function __construct(\PHPCI\Builder $phpci, array $options = array())
|
|
|
|
{
|
|
|
|
$this->phpci = $phpci;
|
2013-07-19 15:40:16 +02:00
|
|
|
$this->rules = isset($options['rules']) ? (array)$options['rules'] : array('codesize', 'unusedcode', 'naming');
|
2013-05-16 16:50:19 +02:00
|
|
|
}
|
2013-05-03 17:02:53 +02:00
|
|
|
|
2013-05-16 18:17:29 +02:00
|
|
|
/**
|
|
|
|
* Runs PHP Mess Detector in a specified directory.
|
|
|
|
*/
|
2013-05-16 16:50:19 +02:00
|
|
|
public function execute()
|
|
|
|
{
|
|
|
|
$ignore = '';
|
|
|
|
|
|
|
|
if (count($this->phpci->ignore)) {
|
2013-05-16 17:46:30 +02:00
|
|
|
$ignore = ' --exclude ' . implode(',', $this->phpci->ignore);
|
2013-05-16 16:50:19 +02:00
|
|
|
}
|
2013-05-03 17:02:53 +02:00
|
|
|
|
2013-07-19 15:40:16 +02:00
|
|
|
$cmd = PHPCI_BIN_DIR . 'phpmd "%s" text %s %s';
|
|
|
|
return $this->phpci->executeCommand($cmd, $this->phpci->buildPath, implode(',', $this->rules), $ignore);
|
2013-05-16 16:50:19 +02:00
|
|
|
}
|
|
|
|
}
|