Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Tool/Phplint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace piotrpasich\CodeQualityThreshold\Tool;

use piotrpasich\CodeQualityThreshold\Tool\Tool;
use Symfony\Component\OptionsResolver\OptionsResolver;

class Phplint extends Tool
{

protected $defaultOptions = [
'directory' => 'src',
'command' => "find",
'threshold' => 0,
'timeout' => 1200
];

public function composeCommand()
{
return "{$this->composeReportCommand()} | grep -v 'No syntax error' | wc -l";
}

public function composeReportCommand()
{
return "{$this->configuration['command']} {$this->configuration['directory']} -name '*.php' -exec php -l {} \\;";
}

public function getThreshold()
{
return isset($this->configuration['threshold']) ? $this->configuration['threshold'] : 0;
}

public function getErrorMessage()
{
return 'The PHP Lint threshold is exceeded';
}

public function getSuccessMessage()
{
return 'The PHP Lint threshold passed';
}
}