From 0c7f0451c27b6e50985fda1733b74a791e8aa197 Mon Sep 17 00:00:00 2001 From: Ener-Getick Date: Tue, 20 Oct 2015 13:46:13 +0200 Subject: [PATCH] Fix php standards --- .gitignore | 1 + .php_cs | 32 ++++++++++++++++++++++++++ .travis.yml | 29 +++++++++++++++++++++++ Exception/InvalidArgumentException.php | 9 ++++++++ Exception/SecurityException.php | 9 ++++++++ Exception/TooShortKeyException.php | 9 ++++++++ README.md | 24 +++++++++++++++++-- TOTP/TOTP.php | 9 ++++++++ TOTP/TOTPGenerator.php | 11 ++++++++- TOTP/TOTPKeyGenerator.php | 11 ++++++++- TOTP/TOTPTimeManager.php | 9 ++++++++ TOTP/TOTPValidator.php | 11 ++++++++- TOTP/Tests/KeyGenerationTest.php | 11 ++++++++- TOTP/Tests/TimeManagerTest.php | 11 ++++++++- TOTP/Tests/ValidatorTest.php | 13 +++++++++-- composer.json | 22 ++++++++++-------- 16 files changed, 203 insertions(+), 18 deletions(-) create mode 100644 .php_cs create mode 100644 .travis.yml diff --git a/.gitignore b/.gitignore index 758269d..80ae21a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /vendor/* composer.lock +.php_cs.cache diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..e1f4689 --- /dev/null +++ b/.php_cs @@ -0,0 +1,32 @@ +in(__DIR__) +; + +$header = <<level(FixerInterface::SYMFONY_LEVEL) + ->fixers([ + 'align_double_arrow', + 'header_comment', + 'ordered_use', + 'short_array_syntax', + ]) + ->finder($finder) + ->setUsingCache(true) +; diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..fe79f81 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +language: php + +php: + - 5.5 + - 5.6 + - 7.0 + - hhvm + +sudo: false + +cache: + directories: + - $HOME/.composer/cache + +branches: + only: + - master + - /^\d+\.\d+$/ + +matrix: + fast_finish: true + include: + - php: 5.5 + env: COMPOSER_FLAGS="--prefer-lowest" + +before_install: + - composer self-update + +install: composer update $COMPOSER_FLAGS --prefer-dist diff --git a/Exception/InvalidArgumentException.php b/Exception/InvalidArgumentException.php index 8015078..6a74b07 100644 --- a/Exception/InvalidArgumentException.php +++ b/Exception/InvalidArgumentException.php @@ -1,5 +1,14 @@ window; $st <= $stamp + $this->window; $st++) { + for ($st = $stamp - $this->window; $st <= $stamp + $this->window; ++$st) { if (($res = TOTPGenerator::generate($st, $key)) == $totp) { return $st; } diff --git a/TOTP/Tests/KeyGenerationTest.php b/TOTP/Tests/KeyGenerationTest.php index 9673d9a..a127835 100644 --- a/TOTP/Tests/KeyGenerationTest.php +++ b/TOTP/Tests/KeyGenerationTest.php @@ -1,5 +1,14 @@ assertRegExp(sprintf('#[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]{%d}#', $length), $key); diff --git a/TOTP/Tests/TimeManagerTest.php b/TOTP/Tests/TimeManagerTest.php index 6f63173..9f84a53 100644 --- a/TOTP/Tests/TimeManagerTest.php +++ b/TOTP/Tests/TimeManagerTest.php @@ -1,5 +1,14 @@ tm = []; - for ($i = 0; $i < 10; $i++) { + for ($i = 0; $i < 10; ++$i) { $l = rand(1, 120); $this->tm[$l] = new TOTPTimeManager($l); } diff --git a/TOTP/Tests/ValidatorTest.php b/TOTP/Tests/ValidatorTest.php index d825ce9..e4a1347 100644 --- a/TOTP/Tests/ValidatorTest.php +++ b/TOTP/Tests/ValidatorTest.php @@ -1,5 +1,14 @@ stamp + rand(-300, 300); - for ($i = -5; $i <= 5; $i++) { + for ($i = -5; $i <= 5; ++$i) { $totp = TOTPGenerator::generate($stamp + $i, $this->key); $this->assertEquals($stamp + $i, $this->validator->validate($totp, $this->key, $stamp + $i), sprintf('Error during checking totp "%s" with the key "%s", the stamp "%d" and with %s stamp added', $totp, $this->key, $stamp, $i)); diff --git a/composer.json b/composer.json index 1f99da3..e90bffe 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "exsyst/security-component", + "name": "exsyst/security", "type": "library", "description": "Provides some security helpers", "license": "Apache-2.0", @@ -10,15 +10,19 @@ ], "minimum-stability": "dev", "require": { - "php": ">=5.3.0" + "php": ">=5.5.0" }, "require-dev": { - "phpunit/phpunit": "~4" + "symfony/phpunit-bridge": "~2.7|^3.0" }, - "autoload": { - "psr-0": { - "EXSyst\\Component\\Security": "" - } - }, - "target-dir": "EXSyst/Component/Security" + "autoload": { + "psr-4": { + "EXSyst\\Component\\Security\\": "" + } + }, + "extra": { + "branch-alias": { + "dev-master": "0.0.x-dev" + } + } }