Skip to content

Commit 2c9c922

Browse files
authored
chore: laravel 12 (#71)
* chore: laravel 12 * Fix styling * min stability * better name * better name * better name * fix * coverage * update readme * update tests * add tests * Fix styling * Trigger Build --------- Co-authored-by: pulkitjalan <[email protected]>
1 parent 611b80d commit 2c9c922

28 files changed

+402
-216
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: dependabot-auto-merge
2+
3+
on: pull_request_target
4+
5+
permissions:
6+
pull-requests: write
7+
contents: write
8+
9+
jobs:
10+
dependabot:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.actor == 'dependabot[bot]' }}
13+
steps:
14+
15+
- name: Dependabot metadata
16+
id: metadata
17+
uses: dependabot/[email protected]
18+
with:
19+
github-token: "${{ secrets.GITHUB_TOKEN }}"
20+
21+
- name: Auto-merge Dependabot PRs for semver-minor updates
22+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
23+
run: gh pr merge --auto --squash "$PR_URL"
24+
env:
25+
PR_URL: ${{github.event.pull_request.html_url}}
26+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
27+
28+
- name: Auto-merge Dependabot PRs for semver-patch updates
29+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
30+
run: gh pr merge --auto --squash "$PR_URL"
31+
env:
32+
PR_URL: ${{github.event.pull_request.html_url}}
33+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/php-cs-fixer.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
name: Check & fix styling
1+
name: pint
22

33
on: [push]
44

55
jobs:
6-
php-cs-fixer:
7-
runs-on: ubuntu-latest
6+
php-cs-fixer:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: write
810

9-
steps:
10-
- name: Checkout code
11-
uses: actions/checkout@v4
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
with:
15+
ref: ${{ github.head_ref }}
1216

13-
- name: Run PHP CS Fixer
14-
uses: docker://oskarstark/php-cs-fixer-ga
15-
with:
16-
args: --config=.php_cs.dist.php --allow-risky=yes
17+
- name: Fix styling issues
18+
uses: aglipanci/laravel-pint-action@v2
1719

18-
- name: Commit changes
19-
uses: stefanzweifel/git-auto-commit-action@v5
20-
with:
21-
commit_message: Fix styling
20+
- name: Commit changes
21+
uses: stefanzweifel/git-auto-commit-action@v5
22+
with:
23+
commit_message: Fix styling

.github/workflows/run-tests.yml

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,47 @@
1-
name: "Run Tests"
1+
name: run-tests
22

33
on:
44
push:
5+
branches:
6+
- main
57
pull_request:
8+
branches:
9+
- main
610
schedule:
7-
- cron: "0 0 * * *"
11+
- cron: '0 0 * * *'
812

913
jobs:
1014
test:
11-
1215
runs-on: ubuntu-latest
16+
1317
strategy:
1418
fail-fast: false
1519
matrix:
16-
php: [8.3, 8.2, 8.1]
17-
laravel: ["^11.0", "^10.0"]
18-
dependency-version: [prefer-lowest, prefer-stable]
19-
exclude:
20-
- laravel: "^11.0"
21-
php: 8.1
20+
php:
21+
- 8.4
22+
- 8.3
23+
- 8.2
24+
- 8.1
25+
laravel:
26+
- 12.0
27+
- 11.0
28+
- 10.0
29+
dependency-version:
30+
- prefer-lowest
31+
- prefer-stable
32+
exclude:
33+
- laravel: 12.0
34+
php: 8.1
35+
- laravel: 11.0
36+
php: 8.1
37+
include:
38+
- with_coverage: false
39+
- with_coverage: true
40+
php: 8.3
41+
laravel: 11.0
42+
dependency-version: prefer-stable
2243

23-
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
44+
name: "PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }}"
2445

2546
steps:
2647
- name: Checkout code
@@ -35,13 +56,22 @@ jobs:
3556

3657
- name: Install dependencies
3758
run: |
38-
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
59+
composer require "laravel/framework:^${{ matrix.laravel }}" --no-interaction --no-update
3960
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
4061
41-
- name: Execute tests
42-
run: vendor/bin/pest tests
62+
- name: Execute tests - without coverage
63+
if: matrix.with_coverage == false
64+
run: vendor/bin/pest
65+
66+
- name: Execute tests - with coverage
67+
id: test
68+
if: matrix.with_coverage == true
69+
run: vendor/bin/pest --coverage
4370

44-
- uses: codecov/codecov-action@v5
71+
- name: Upload coverage reports to Codecov
72+
if: matrix.with_coverage == true
73+
uses: codecov/codecov-action@v5
4574
with:
4675
token: ${{ secrets.CODECOV_TOKEN }}
4776
directory: build
77+
verbose: true

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ IP Geolocation
33

44
> IP Geolocation Wrapper with Laravel Support
55
6-
[![Latest Stable Version](https://poser.pugx.org/pulkitjalan/ip-geolocation/v/stable)](https://packagist.org/packages/pulkitjalan/ip-geolocation)
7-
[![Total Downloads](https://poser.pugx.org/pulkitjalan/ip-geolocation/downloads)](https://packagist.org/packages/pulkitjalan/ip-geolocation)
8-
[![License](https://poser.pugx.org/pulkitjalan/ip-geolocation/license)](https://packagist.org/packages/pulkitjalan/ip-geolocation)
6+
[![Latest Stable Version](https://poser.pugx.org/pulkitjalan/ip-geolocation/v/stable?format=flat-square)](https://packagist.org/packages/pulkitjalan/ip-geolocation)
7+
[![MIT License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](http://www.opensource.org/licenses/MIT)
8+
[![Run Tests](https://github.com/pulkitjalan/ip-geolocation/actions/workflows/run-tests.yml/badge.svg)](https://github.com/pulkitjalan/ip-geolocation/actions/workflows/run-tests.yml)
9+
[![Coverage](https://codecov.io/gh/pulkitjalan/ip-geolocation/graph/badge.svg?token=dpjZ4Tszxm)](https://codecov.io/gh/pulkitjalan/ip-geolocation)
10+
[![Total Downloads](https://img.shields.io/packagist/dt/pulkitjalan/ip-geolocation.svg?style=flat-square)](https://packagist.org/packages/pulkitjalan/ip-geolocation)
911

1012

1113
This package provides an easy way to get geolocation information from IP addresses. It supports multiple drivers including IP-API, MaxMind Database, MaxMind API, IPStack, IP2Location, and IPinfo.

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
],
1818
"require": {
1919
"php": "^8.1",
20-
"illuminate/support": "^10.0|^11.0",
21-
"illuminate/console": "^10.0|^11.0",
20+
"illuminate/support": "^10.0|^11.0|^12.0",
21+
"illuminate/console": "^10.0|^11.0|^12.0",
2222
"guzzlehttp/guzzle": "^7.5|^7.8",
2323
"geoip2/geoip2": "^3.0"
2424
},
2525
"require-dev": {
2626
"mockery/mockery": "^1.6",
27-
"pestphp/pest": "^1.20|^2.0"
27+
"pestphp/pest": "^1.20|^2.0|^3.7"
2828
},
2929
"autoload": {
3030
"psr-4": {
@@ -49,6 +49,8 @@
4949
}
5050
}
5151
},
52+
"minimum-stability": "dev",
53+
"prefer-stable": true,
5254
"scripts": {
5355
"test": "vendor/bin/pest"
5456
},

config/ip-geolocation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
'maxmind_api' => [
5151
'user_id' => env('IPGEOLOCATION_MAXMIND_USER_ID'),
5252
'license_key' => env('IPGEOLOCATION_MAXMIND_LICENSE_KEY'),
53-
//maxmind api will default to paid service. Use 'geolite.info' for free GeoLite2 Web service. https://github.com/maxmind/GeoIP2-php#usage-1
53+
// maxmind api will default to paid service. Use 'geolite.info' for free GeoLite2 Web service. https://github.com/maxmind/GeoIP2-php#usage-1
5454
'host' => env('IPGEOLOCATION_MAXMIND_HOST'),
55-
//local required on client call but defaults to 'en' for english.
55+
// local required on client call but defaults to 'en' for english.
5656
'locales' => ['en'],
5757
],
5858

pint.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"preset": "laravel",
3+
"rules": {
4+
"ordered_imports": {
5+
"sort_algorithm": "length"
6+
}
7+
}
8+
}

src/Drivers/AbstractIPGeolocationDriver.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ abstract class AbstractIPGeolocationDriver
1616
*/
1717
protected $guzzle;
1818

19-
/**
20-
* @param array $config
21-
*/
22-
public function __construct(array $config, GuzzleClient $guzzle = null)
19+
public function __construct(array $config, ?GuzzleClient $guzzle = null)
2320
{
2421
$this->config = $config;
2522

26-
$this->guzzle = $guzzle ?? new GuzzleClient();
23+
$this->guzzle = $guzzle ?? new GuzzleClient;
2724
}
2825

2926
/**

src/Drivers/IP2LocationDriver.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
class IP2LocationDriver extends AbstractIPGeolocationDriver implements IPGeolocationInterface
1010
{
1111
/**
12-
* @param array $config
13-
* @param GuzzleClient|null $guzzle
1412
* @throws InvalidCredentialsException
1513
*/
16-
public function __construct(array $config, GuzzleClient $guzzle = null)
14+
public function __construct(array $config, ?GuzzleClient $guzzle = null)
1715
{
1816
parent::__construct($config, $guzzle);
1917

@@ -25,7 +23,7 @@ public function __construct(array $config, GuzzleClient $guzzle = null)
2523
/**
2624
* Get array of data using IP2Location.
2725
*
28-
* @param string $ip
26+
* @param string $ip
2927
* @return array
3028
*/
3129
public function get($ip)
@@ -52,7 +50,7 @@ public function get($ip)
5250
/**
5351
* Get the raw IP2Location info.
5452
*
55-
* @param string $ip
53+
* @param string $ip
5654
* @return array
5755
*/
5856
public function getRaw($ip)
@@ -66,7 +64,7 @@ public function getRaw($ip)
6664
/**
6765
* Get the IP2Location API URL.
6866
*
69-
* @param string $ip
67+
* @param string $ip
7068
* @return string
7169
*/
7270
protected function getUrl($ip)

src/Drivers/IPApiDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function getUrl($ip)
6464
$key = Arr::get($this->config, 'key');
6565
}
6666

67-
//default language English
67+
// default language English
6868
$lang = 'en';
6969

7070
if (Arr::get($this->config, 'lang', false)) {

0 commit comments

Comments
 (0)