phpci/PHPCI/Plugin/PhpCpd.php

46 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 Copy / Paste Detector - Allows PHP Copy / Paste Detector testing.
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Plugins
*/
2013-05-03 17:02:53 +02:00
class PhpCpd implements \PHPCI\Plugin
{
protected $directory;
protected $args;
protected $phpci;
2013-05-03 17:02:53 +02:00
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';
}
2013-05-03 17:02:53 +02:00
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);
2013-05-03 17:02:53 +02:00
$ignore = implode('', $ignore);
}
2013-05-03 17:02:53 +02:00
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpcpd %s "%s"', $ignore, $this->phpci->buildPath);
}
}