Skip to content

Commit

Permalink
Merge pull request #2 from imliam/laravel-8
Browse files Browse the repository at this point in the history
Add Laravel 8 support
  • Loading branch information
imliam authored Sep 13, 2020
2 parents 6341a46 + f550109 commit ab0d0d8
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 26 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: imliam
41 changes: 41 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Run Tests
on: [push]

jobs:
run:
runs-on: ubuntu-latest
strategy:
max-parallel: 15
fail-fast: false
matrix:
php-versions: ['7.3', '7.4']
composer-flags: ['--prefer-lowest', '--prefer-stable']
env:
- LARAVEL_VERSION='^7.0' TESTBENCH_VERSION='^5.0'
- LARAVEL_VERSION='^8.0' TESTBENCH_VERSION='^6.0'
name: Test on PHP ${{ matrix.php-versions }}, Laravel ${{ matrix.laravel-versions }} and ${{ matrix.composer-flags }}
steps:
- name: Checkout
uses: actions/checkout@master
- name: Install PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
- name: Check Environment
run: |
${{ matrix.env }}
php -v
composer -V
php -m
echo "Laravel version ${LARAVEL_VERSION}"
echo "Orchestra Testbench version ${TESTBENCH_VERSION}"
- name: Install Dependencies
run: |
${{ matrix.env }}
composer config discard-changes true
composer self-update
composer require --dev "laravel/framework:${LARAVEL_VERSION}" --no-interaction --no-update
composer require --dev "orchestra/testbench:${TESTBENCH_VERSION}" --no-interaction --no-update
composer update ${{ matrix.composer-flags }} --prefer-dist --no-suggest --no-interaction
- name: Run PHPUnit
run: php vendor/bin/phpunit
18 changes: 0 additions & 18 deletions .scrutinizer.yml

This file was deleted.

1 change: 0 additions & 1 deletion .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ preset: laravel

disabled:
- single_class_element_per_statement
- self_accessor
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ When performing an action only the current user can perform, this also helps to
You can install the package with [Composer](https://getcomposer.org/) using the following command:

```bash
composer require imliam/laravel-throttle-simultaneous-requests:^1.0.0
composer require imliam/laravel-throttle-simultaneous-requests:^2.0.0
```

Once installed to your project, add the middleware to your `App\Http\Kernel::$routeMiddleware` array.
Expand Down
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
}
],
"require": {
"php": "^7.1"
"php": "^7.3",
"illuminate/http": "^7.0|^8.0",
"illuminate/support": "^7.0|^8.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^7.0|^8.0|^9.0",
"larapack/dd": "^1.0",
"orchestra/testbench": "^3.6.0"
"orchestra/testbench": "^5.0|^6.0"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 3 additions & 3 deletions src/ThrottleSimultaneousRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
class ThrottleSimultaneousRequests
{
/**
* Amount of time (in minutes) the last request will be stored,
* Amount of time (in seconds) the last request will be stored,
* in the cache, in the case the middleware never terminates.
*
* @var integer
*/
protected $cacheForMinutes = 60;
protected $cacheForSeconds = 3600;

/**
* The limit of concurrent requests the current user can run.
Expand Down Expand Up @@ -149,7 +149,7 @@ protected function increment(): int
$value = Cache::get($this->signature) + 1;
}

Cache::put($this->signature, $value, $this->cacheForMinutes);
Cache::put($this->signature, $value, $this->cacheForSeconds);

return $value;
}
Expand Down

0 comments on commit ab0d0d8

Please sign in to comment.