Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #9 from Sweetchuck/code-refactor
Browse files Browse the repository at this point in the history
Code refactor
  • Loading branch information
Sweetchuck authored Jul 30, 2017
2 parents 48c34a7 + ab40739 commit 2683454
Show file tree
Hide file tree
Showing 18 changed files with 354 additions and 356 deletions.
2 changes: 1 addition & 1 deletion .git-hooks
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ echo "BEGIN Git hook: ${sghHookName}"

function myExit ()
{
echo "End Git hook: ${sghHookName}"
echo "END Git hook: ${sghHookName}"

exit $1
}
Expand Down
55 changes: 14 additions & 41 deletions RoboFile.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?php

// @codingStandardsIgnoreStart
use Robo\Collection\CollectionBuilder;
use Sweetchuck\LintReport\Reporter\BaseReporter;
use Sweetchuck\LintReport\Reporter\CheckstyleReporter;
use League\Container\ContainerInterface;
use Symfony\Component\Process\Process;
use Symfony\Component\Yaml\Yaml;

/**
* Class RoboFile.
*/
class RoboFile extends \Robo\Tasks
// @codingStandardsIgnoreEnd
{
Expand Down Expand Up @@ -58,9 +56,6 @@ class RoboFile extends \Robo\Tasks
*/
protected $environment = '';

/**
* RoboFile constructor.
*/
public function __construct()
{
putenv('COMPOSER_DISABLE_XDEBUG_WARN=1');
Expand All @@ -80,7 +75,7 @@ public function setContainer(ContainerInterface $container)
/**
* @return string
*/
protected function getEnvironment()
protected function getEnvironment(): string
{
if ($this->environment) {
return $this->environment;
Expand All @@ -91,43 +86,35 @@ protected function getEnvironment()

/**
* Git "pre-commit" hook callback.
*
* @return \Robo\Collection\CollectionBuilder
*/
public function githookPreCommit()
public function githookPreCommit(): CollectionBuilder
{
$this->environment = 'git-hook';

return $this
->collectionBuilder()
->addTaskList([
'lint.composer.lock' => $this->taskComposerValidate(),
'lint.phpcs.psr2' => $this->getTaskPhpcsLint(),
'codecept' => $this->getTaskCodecept(),
]);
->addTask($this->taskComposerValidate())
->addTask($this->getTaskPhpcsLint())
->addTask($this->getTaskCodecept());
}

/**
* Run the Robo unit tests.
*/
public function test()
public function test(): CollectionBuilder
{
return $this->getTaskCodecept();
}

/**
* Run code style checkers.
*
* @return \Robo\Collection\CollectionBuilder
*/
public function lint()
public function lint(): CollectionBuilder
{
return $this
->collectionBuilder()
->addTaskList([
'lint.composer.lock' => $this->taskComposerValidate(),
'lint.phpcs.psr2' => $this->getTaskPhpcsLint(),
]);
->addTask($this->taskComposerValidate())
->addTask($this->getTaskPhpcsLint());
}

/**
Expand Down Expand Up @@ -171,10 +158,7 @@ protected function initCodeceptionInfo()
return $this;
}

/**
* @return \Robo\Collection\CollectionBuilder
*/
protected function getTaskCodecept()
protected function getTaskCodecept(): CollectionBuilder
{
$environment = $this->getEnvironment();
$withCoverage = $environment !== 'git-hook';
Expand Down Expand Up @@ -283,12 +267,7 @@ protected function getTaskPhpcsLint()
->deferTaskConfiguration('setFiles', 'files'));
}

/**
* @param string $extension
*
* @return bool
*/
protected function isPhpExtensionAvailable($extension)
protected function isPhpExtensionAvailable(string $extension): bool
{
$command = sprintf('%s -m', escapeshellcmd($this->phpExecutable));

Expand All @@ -301,10 +280,7 @@ protected function isPhpExtensionAvailable($extension)
return in_array($extension, explode("\n", $process->getOutput()));
}

/**
* @return bool
*/
protected function isPhpDbgAvailable()
protected function isPhpDbgAvailable(): bool
{
$command = sprintf(
'%s -i | grep -- %s',
Expand All @@ -315,10 +291,7 @@ protected function isPhpDbgAvailable()
return (new Process($command))->run() === 0;
}

/**
* @return string
*/
protected function getLogDir()
protected function getLogDir(): string
{
$this->initCodeceptionInfo();

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
"consolidation/robo": "^1.0"
},
"require-dev": {
"codeception/codeception": "^2.2",
"sweetchuck/codeception-module-robo-task-runner": "^0.0.1",
"sweetchuck/git-hooks": "^0.0",
"sweetchuck/lint-report": "^0.0",
"sweetchuck/robo-git": "^0.0",
"sweetchuck/robo-phpcs": "^0.0",
"codeception/codeception": "^2.2",
"symfony/process": "^2.8 || ^3.1"
},
"autoload": {
Expand Down
37 changes: 36 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2683454

Please sign in to comment.