From d05bf812a02f9db0f675fc278a002b7135e1a3bd Mon Sep 17 00:00:00 2001 From: Matt McDonald Date: Fri, 6 Mar 2020 10:31:46 +0000 Subject: [PATCH] Laravel 7 support; simplify check for version The simplified version check will prevent the clause growing exponentially with each new release. --- composer.json | 6 +++--- src/Msurguy/Honeypot/HoneypotServiceProvider.php | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 781cbb8..863d160 100644 --- a/composer.json +++ b/composer.json @@ -16,9 +16,9 @@ ], "require": { "php": ">=5.3.0", - "illuminate/support": "4.*|5.*|6.*", - "illuminate/config": "4.*|5.*|6.*", - "illuminate/translation": "4.*|5.*|6.*" + "illuminate/support": "4.*|5.*|6.*|7.*", + "illuminate/config": "4.*|5.*|6.*|7.*", + "illuminate/translation": "4.*|5.*|6.*|7.*" }, "require-dev": { "phpunit/phpunit": "4.0.*", diff --git a/src/Msurguy/Honeypot/HoneypotServiceProvider.php b/src/Msurguy/Honeypot/HoneypotServiceProvider.php index 4caf1e3..a6298a4 100644 --- a/src/Msurguy/Honeypot/HoneypotServiceProvider.php +++ b/src/Msurguy/Honeypot/HoneypotServiceProvider.php @@ -33,10 +33,10 @@ public function register() */ public function boot() { - if ($this->isLaravelVersion('4')) { - $this->package('msurguy/honeypot'); - } elseif ($this->isLaravelVersion('5') || $this->isLaravelVersion('6')) { + if ($this->isLaravelMinimumVersion(5)) { $this->loadTranslationsFrom(__DIR__ . '/../../lang', 'honeypot'); + } else { + $this->package('msurguy/honeypot'); } $this->app->booted(function ($app) { @@ -62,13 +62,13 @@ public function provides() } /** - * Determine if laravel starts with any of the given version strings + * Determine if Laravel version is at least the given version. * - * @param string|array $startsWith + * @param string|array $minimumVersion * @return boolean */ - protected function isLaravelVersion($startsWith) + protected function isLaravelMinimumVersion($minimumVersion) { - return Str::startsWith(Application::VERSION, $startsWith); + return (float)Application::VERSION >= $minimumVersion; } }