Skip to content

Commit

Permalink
Merge pull request #9 from Hexmedia/feature/better-style-checking
Browse files Browse the repository at this point in the history
Better style checking in project.
  • Loading branch information
kuczek committed Feb 14, 2016
2 parents d581af8 + 7cd5a13 commit cd39594
Show file tree
Hide file tree
Showing 73 changed files with 1,006 additions and 486 deletions.
2 changes: 1 addition & 1 deletion .composer-auth.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"github-oauth": {
"github.com": "PLEASE DO NOT USE THIS TOKEN IN YOUR OWN PROJECTS/FORKS",
"github.com": "This token is reserved for testing the symfony/symfony repository",
"github.com": "This token is reserved for testing the Hexmedia/Crontab repository",
"github.com": "7ef309823a135cbd4d0bc02940178a783b23c522"
}
}
5 changes: 5 additions & 0 deletions Tests/spec/Console/ClearCommandSpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\Console;

Expand Down
5 changes: 5 additions & 0 deletions Tests/spec/Console/EchoCommandSpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\Console;

Expand Down
5 changes: 5 additions & 0 deletions Tests/spec/Console/SynchronizeCommandSpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\Console;

Expand Down
5 changes: 5 additions & 0 deletions Tests/spec/CrontabSpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab;

Expand Down
7 changes: 6 additions & 1 deletion Tests/spec/Parser/Unix/ParserFactorySpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\Parser\Unix;

Expand All @@ -10,6 +15,6 @@ class ParserFactorySpec extends ObjectBehavior
function it_is_initializable()
{
$this->shouldHaveType('Hexmedia\Crontab\Parser\Unix\ParserFactory');
$this->shouldImplement('Hexmedia\Crontab\Parser\ParserFactoryAbstract');
$this->shouldImplement('Hexmedia\Crontab\Parser\AbstractParserFactory');
}
}
6 changes: 6 additions & 0 deletions Tests/spec/Parser/Unix/UnixParserSpec.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\Parser\Unix;

use Hexmedia\Crontab\Parser\Unix\UnixParser;
use Hexmedia\Crontab\Parser\Unix\UnixParserAbstract;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

Expand Down
5 changes: 5 additions & 0 deletions Tests/spec/Parser/Yaml/ParserFactorySpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\Parser\Yaml;

Expand Down
5 changes: 5 additions & 0 deletions Tests/spec/Reader/SystemReaderSpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\Reader;

Expand Down
7 changes: 6 additions & 1 deletion Tests/spec/Reader/UnixFileReaderSpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\Reader;

Expand All @@ -15,7 +20,7 @@ function let()
function it_is_initializable()
{
$this->shouldHaveType('Hexmedia\Crontab\Reader\UnixFileReader');
$this->shouldImplement('Hexmedia\Crontab\Reader\UnixReader');
$this->shouldImplement('Hexmedia\Crontab\Reader\AbstractUnixReader');
}

function it_is_readable() {
Expand Down
7 changes: 6 additions & 1 deletion Tests/spec/Reader/UnixSystemReaderSpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\Reader;

Expand All @@ -25,7 +30,7 @@ function let()
function it_is_initializable()
{
$this->shouldHaveType('Hexmedia\Crontab\Reader\UnixSystemReader');
$this->shouldImplement('Hexmedia\Crontab\Reader\UnixReader');
$this->shouldImplement('Hexmedia\Crontab\Reader\AbstractUnixReader');
}

function it_is_supported()
Expand Down
5 changes: 5 additions & 0 deletions Tests/spec/Reader/YamlReaderSpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\Reader;

Expand Down
5 changes: 5 additions & 0 deletions Tests/spec/ReaderFactorySpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab;

Expand Down
5 changes: 5 additions & 0 deletions Tests/spec/System/UnixSpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\System;

Expand Down
5 changes: 5 additions & 0 deletions Tests/spec/TaskSpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab;

Expand Down
5 changes: 5 additions & 0 deletions Tests/spec/VariablesSpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab;

Expand Down
6 changes: 5 additions & 1 deletion Tests/spec/Writer/System/UnixWriterSpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\Writer\System;

Expand All @@ -10,7 +15,6 @@

class UnixWriterSpec extends ObjectBehavior
{

private function prepareTask(&$task, $variables, $notManaged = false)
{
$task->getCommand()->willReturn("test");
Expand Down
5 changes: 5 additions & 0 deletions Tests/spec/Writer/System/WriterFactorySpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\Writer\System;

Expand Down
5 changes: 5 additions & 0 deletions Tests/spec/Writer/SystemWriterSpec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace spec\Hexmedia\Crontab\Writer;

Expand Down
7 changes: 5 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<property name="build.report.dir.phploc" value="${build.report.dir}/phploc"/>
<property name="build.report.dir.phpdcd" value="${build.report.dir}/phpdcd"/>

<property name="build.phpcs.standard"
value="${project.basedir}/vendor/hexmedia/code-style/src/Hexmedia/"/>

<property name="build.config.dir" value="${build.dir}/config"/>
<property name="build.config.file.phpmd" value="${build.config.dir}/phpmd.xml"/>
<property name="build.config.file.phpspec" value="${build.config.dir}/phpspec.yml"/>
Expand Down Expand Up @@ -139,7 +142,7 @@
</target>

<target name="phpcs">
<phpcodesniffer haltonerror="true" haltonwarning="true" verbosity="1" standard="PSR2">
<phpcodesniffer haltonerror="true" haltonwarning="true" verbosity="1" standard="${build.phpcs.standard}">
<formatter type="full" outfile="${build.report.dir.phpcs}/report.txt"/>
<fileset refid="project"/>
</phpcodesniffer>
Expand All @@ -148,7 +151,7 @@
<target name="phpcbf">
<exec dir="${project.basedir}" executable="${bin}/phpcbf">
<arg line="-w"/>
<arg line="--standard=PSR2"/>
<arg line="--standard=${build.phpcs.standard}"/>
<arg line="${src}"/>
</exec>
</target>
Expand Down
13 changes: 8 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@
},
"require": {
"php": ">=5.3.3",
"symfony/console": ">=2.3,<4"
"symfony/console": ">=2.3,<4.0"
},
"require-dev": {
"phpunit/phpunit" : ">=4.0,<6",
"sebastian/phpcpd": "^2.0",
"sebastian/phpdcd": "^1.0",
"phpspec/phpspec": "~2.4",
"henrikbjorn/phpspec-code-coverage": ">1,<3",
"henrikbjorn/phpspec-code-coverage": ">1.0,<3.0",
"symfony/yaml": ">=2.3,<4",
"symfony/config": ">=2.3,<4",
"austinhyde/iniparser": "~1.0@dev",
"zf1/zend-config" : "1.12.11",
"zendframework/zend-config": "~2.5",
"phpmd/phpmd": "~2.3",
"phpmd/phpmd": "~2.3,>=2.3.1",
"pdepend/pdepend": "~2.1",
"squizlabs/php_codesniffer": "^2.5",
"phploc/phploc": ">=2.0,<4",
"symfony/process": ">=2.3,<4",
"seld/jsonlint": "^1.4",
"hexmedia/yaml-linter": "^0.2.0",
"sclable/xml-lint": "^0.2.1"
"hexmedia/yaml-linter": "<2",
"hexmedia/code-style": "dev-crontab"
},
"suggest": {
"symfony/yaml": "Enables support for yaml configuration files.",
Expand All @@ -55,5 +55,8 @@
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"scripts": {
"post-autoload-dump": "./vendor/hexmedia/code-style/install.sh"
}
}
50 changes: 33 additions & 17 deletions src/Console/AbstractCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/

namespace Hexmedia\Crontab\Console;

Expand All @@ -12,23 +17,41 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Class CommandAbstract
*
* @package Hexmedia\Crontab\Console
*/
abstract class AbstractCommand extends Command
{

/**
* @param OutputInterface $output
* @param Crontab $crontab
* @param string|null $user
*
* @return mixed
*/
abstract public function output(OutputInterface $output, Crontab $crontab, $user = null);

/**
*
*/
protected function configure()
{
$this
->addOption("machine", "m", InputOption::VALUE_OPTIONAL, "Machine name to synchronize")
->addOption("user", "u", InputOption::VALUE_OPTIONAL, "Username for synchronization (crontab -u)")
->addOption("type", "t", InputOption::VALUE_REQUIRED, "Type of parsed file, if not given system will guess")
->addOption("dry-run", null, InputOption::VALUE_OPTIONAL, "Do not write crontab file");
->addOption('machine', 'm', InputOption::VALUE_OPTIONAL, 'Machine name to synchronize')
->addOption('user', 'u', InputOption::VALUE_OPTIONAL, 'Username for synchronization (crontab -u)')
->addOption('type', 't', InputOption::VALUE_REQUIRED, 'Type of parsed file, if not given system will guess')
->addOption('dry-run', null, InputOption::VALUE_OPTIONAL, 'Do not write crontab file');

$this->configureArguments();
$this->configureName();
}

/**
* @return mixed
*/
abstract protected function configureName();

/**
Expand All @@ -37,20 +60,21 @@ abstract protected function configureName();
protected function configureArguments()
{
$this
->addArgument("configuration-file", InputArgument::REQUIRED, "Configuration file")
->addArgument("name", InputArgument::REQUIRED, "Name of project");
->addArgument('configuration-file', InputArgument::REQUIRED, 'Configuration file')
->addArgument('name', InputArgument::REQUIRED, 'Name of project');
}

/**
* @param InputInterface $input
* @param InputInterface $input
* @param OutputInterface $output
*
* @return null
* @SuppressWarnings(PHPMD.StaticAccess)
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$name = $input->getArgument("name");
$user = $input->getOption("user");
$name = $input->getArgument('name');
$user = $input->getOption('user');

$crontab = new Crontab($user, $name);

Expand All @@ -69,14 +93,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->output($output, $crontab, $user);
}

/**
* @param OutputInterface $output
* @param Crontab $crontab
* @param string|null $user
* @return mixed
*/
abstract public function output(OutputInterface $output, Crontab $crontab, $user = null);

/**
* @param InputInterface $input
*
Expand Down
Loading

0 comments on commit cd39594

Please sign in to comment.