49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* 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/
|
|
*/
|
|
|
|
namespace PHPCI\Plugin;
|
|
|
|
/**
|
|
* PHP Copy / Paste Detector - Allows PHP Copy / Paste Detector testing.
|
|
* @author Dan Cryer <dan@block8.co.uk>
|
|
* @package PHPCI
|
|
* @subpackage Plugins
|
|
*/
|
|
class PhpCpd implements \PHPCI\Plugin
|
|
{
|
|
protected $directory;
|
|
protected $args;
|
|
protected $phpci;
|
|
|
|
public function __construct(\PHPCI\Builder $phpci, array $options = array())
|
|
{
|
|
$this->phpci = $phpci;
|
|
$this->directory = isset($options['directory']) ? $options['directory'] : $phpci->buildPath;
|
|
$this->standard = isset($options['standard']) ? $options['standard'] : 'PSR2';
|
|
}
|
|
|
|
/**
|
|
* Runs PHP Copy/Paste Detector in a specified directory.
|
|
*/
|
|
public function execute()
|
|
{
|
|
$ignore = '';
|
|
if (count($this->phpci->ignore)) {
|
|
$map = function ($item) {
|
|
return ' --exclude ' . (substr($item, -1) == '/' ? substr($item, 0, -1) : $item);
|
|
};
|
|
$ignore = array_map($map, $this->phpci->ignore);
|
|
|
|
$ignore = implode('', $ignore);
|
|
}
|
|
|
|
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpcpd %s "%s"', $ignore, $this->phpci->buildPath);
|
|
}
|
|
}
|