From fc73956165594e658599565455469843749a70da Mon Sep 17 00:00:00 2001 From: Marcus Olsson Date: Sat, 9 Jun 2018 17:21:53 +0200 Subject: [PATCH 1/3] scrutinizer-support. --- .scrutinizer.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .scrutinizer.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..1165e72 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,18 @@ +filter: + excluded_paths: [tests/*] + +checks: + php: + remove_extra_empty_lines: true + remove_php_closing_tag: true + remove_trailing_whitespace: true + fix_use_statements: + remove_unused: true + preserve_multiple: false + preserve_blanklines: true + order_alphabetically: true + fix_php_opening_tag: true + fix_linefeed: true + fix_line_ending: true + fix_identation_4spaces: true + fix_doc_comments: true From 42f9a0ea1140b23145ed743c5b23593b6729271b Mon Sep 17 00:00:00 2001 From: Marcus Olsson Date: Sat, 9 Jun 2018 17:22:22 +0200 Subject: [PATCH 2/3] Cleanup, refactoring. --- LICENSE.md | 2 +- README.md | 32 ++++++++++++++++++++++---------- src/ZxcvbnServiceProvider.php | 18 +++++++++--------- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 5f902f8..0987856 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ # The MIT License (MIT) -Copyright (c) 2017 Marcus Olsson +Copyright (c) 2018 Marcus Olsson > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index df36555..cbe87e9 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ [![Total downloads][ico-downloads]][link-packagist] [![Software License][ico-license]](LICENSE.md) [![Build Status][ico-travis]][link-travis] +[![Scrutinizer Score][ico-scrutinizer]][link-scrutinizer] + +![zxcvbn](https://user-images.githubusercontent.com/907114/41193108-747d9b50-6c08-11e8-8f9c-57874f52fa9b.png) A simple implementation of zxcvbn for Laravel 5. This package allows you to access "zxcvbn-related" data on a passphrase in the application and also to use zxcvbn as a standard validator. @@ -13,13 +16,13 @@ Uses [Zxcvbn-PHP](https://github.com/bjeavons/zxcvbn-php) by [@bjeavons](https:/ Via Composer -``` bash +```bash $ composer require olssonm/l5-zxcvbn ``` Add the package to your providers array: -``` php +```php 'providers' => [ Olssonm\Zxcvbn\ZxcvbnServiceProvider::class, ] @@ -27,7 +30,7 @@ Add the package to your providers array: If you wish to have the ability to use `Zxcvbn` via dependency injection, or just have a quick way to access the class – add an alias to the facades: -``` php +```php 'aliases' => [ 'Zxcvbn' => Olssonm\Zxcvbn\Facades\Zxcvbn::class ] @@ -39,7 +42,7 @@ If you've added `Olssonm\Zxcvbn` as an alias, your can access Zxcvbn easily from ### "In app" -``` php +```php 'password']; $validator = Validator::make($data, [ @@ -102,7 +105,7 @@ This is a bit more interesting. `zxcvbn_dictionary` allows you to input both the **Example** -``` php +```php passwordStrength($value); $target = 5; - if(isset($parameters[0])) { + if (isset($parameters[0])) { $target = $parameters[0]; } return ($zxcvbn['score'] >= $target); }, 'Your :attribute is not secure enough.'); - Validator::replacer('zxcvbn_min', function($message, $attribute, $rule, $parameters) { + Validator::replacer('zxcvbn_min', function($message, $attribute) { $message = str_replace(':attribute', $attribute, $message); return $message; }); @@ -38,11 +38,11 @@ class ZxcvbnServiceProvider extends ServiceProvider /** * Extend the Laravel Validator with the "zxcvbn_min" rule */ - Validator::extend('zxcvbn_dictionary', function($attribute, $value, $parameters, $validator) { + Validator::extend('zxcvbn_dictionary', function($attribute, $value, $parameters) { $email = null; $username = null; - if(isset($parameters[0])) { + if (isset($parameters[0])) { $email = $parameters[0]; $username = $parameters[1]; } @@ -50,9 +50,9 @@ class ZxcvbnServiceProvider extends ServiceProvider $zxcvbn = new ZxcvbnPhp(); $zxcvbn = $zxcvbn->passwordStrength($value, [$username, $email]); - if(isset($zxcvbn['match_sequence'][0])) { + if (isset($zxcvbn['match_sequence'][0])) { $dictionary = $zxcvbn['match_sequence'][0]; - if(isset($dictionary->dictionaryName)) { + if (isset($dictionary->dictionaryName)) { return false; } } @@ -61,7 +61,7 @@ class ZxcvbnServiceProvider extends ServiceProvider }, 'Your :attribute is insecure. It either matches a commonly used password, or you have used a similar username/password combination.'); - Validator::replacer('zxcvbn_dictionary', function($message, $attribute, $rule, $parameters) { + Validator::replacer('zxcvbn_dictionary', function($message, $attribute) { $message = str_replace(':attribute', $attribute, $message); return $message; }); @@ -74,7 +74,7 @@ class ZxcvbnServiceProvider extends ServiceProvider */ public function register() { - $this->app->bind('zxcvbn', function ($app) { + $this->app->bind('zxcvbn', function($app) { return new ZxcvbnPhp(); }); } From 6912dbe3859003e6305873355572ba629585d07d Mon Sep 17 00:00:00 2001 From: Marcus Olsson Date: Sat, 9 Jun 2018 17:22:30 +0200 Subject: [PATCH 3/3] New travis-matrix. --- .travis.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 423b2b9..f9b282d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,13 @@ language: php -before_install: +sudo: false + +before_script: - travis_retry composer self-update - - composer require "illuminate/support:${ILLUMINATE_VERSION}" --no-update + - travis_retry composer require "illuminate/support:${ILLUMINATE_VERSION}" -install: composer update --prefer-source --no-interaction --dev - -script: composer test +script: + - phpunit matrix: include: @@ -20,5 +21,7 @@ matrix: env: ILLUMINATE_VERSION=5.5.* - php: 7.1 env: ILLUMINATE_VERSION=5.6.* + - php: 7.2 + env: ILLUMINATE_VERSION=5.6.* - php: nightly env: ILLUMINATE_VERSION=5.6.*