php-censor/PHPCI/Plugin/PhpMessDetector.php

43 lines
1,016 B
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;
public function __construct(\PHPCI\Builder $phpci, array $options = array())
{
$this->phpci = $phpci;
}
public function execute()
{
$ignore = '';
2013-05-03 17:02:53 +02:00
if(count($this->phpci->ignore))
{
$ignore = array_map(function($item)
{
return substr($item, -1) == '/' ? $item . '*' : $item . '/*';
}, $this->phpci->ignore);
$ignore = ' --exclude ' . implode(',', $ignore);
}
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpmd "%s" text codesize,unusedcode,naming %s', $this->phpci->buildPath, $ignore);
2013-05-03 17:02:53 +02:00
}
}