php-censor/PHPCI/Plugin/PhpMessDetector.php

48 lines
1.3 KiB
PHP
Raw Normal View History

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;
/**
* 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
{
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
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-03 17:02:53 +02:00
/**
* Runs PHP Mess Detector in a specified directory.
*/
public function execute()
{
$ignore = '';
if (count($this->phpci->ignore)) {
$ignore = ' --exclude ' . implode(',', $this->phpci->ignore);
}
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);
}
}