Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ jobs:
php-version: '8.2'
coverage: none

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress
- name: Install composer dependencies
uses: nick-fields/retry@v3
with:
timeout_minutes: 3
max_attempts: 5
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: Run PHPStan
timeout-minutes: 2
Expand Down
25 changes: 11 additions & 14 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.1, 8.2]
laravel: [10.*, 9.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
larastan: 2.4.*
- laravel: 9.*
testbench: 7.*
larastan: 2.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
php: [ 8.4, 8.3, 8.2, 8.1 ]
laravel: ["^12.0", "^11.0", "^10.0" ]
exclude:
- php: 8.1
laravel: "^12.0"
- php: 8.1
laravel: "^11.0"

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.os }}

steps:
- name: Checkout code
Expand All @@ -42,8 +39,8 @@ jobs:

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nunomaduro/larastan:${{ matrix.larastan }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
composer require "laravel/framework:${{ matrix.laravel }}" --dev --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-progress

- name: Execute tests
timeout-minutes: 2
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<h1 align="center">Laravel Social Link Validator</h1>

[![Latest Version on Packagist](https://img.shields.io/packagist/v/ageekdev/laravel-social-link-validator.svg?style=flat-square)](https://packagist.org/packages/ageekdev/laravel-social-link-validator)
[![Laravel 9.x](https://img.shields.io/badge/Laravel-9.x-red.svg?style=flat-square)](https://laravel.com/docs/9.x)
[![Laravel 10.x](https://img.shields.io/badge/Laravel-10.x-red.svg?style=flat-square)](http://laravel.com)
[![Laravel 11.x](https://img.shields.io/badge/Laravel-11.x-red.svg?style=flat-square)](http://laravel.com)
[![Laravel 10.x](https://img.shields.io/badge/Laravel-10.x-red.svg?style=flat-square)](https://laravel.com/docs/10.x)
[![Laravel 11.x](https://img.shields.io/badge/Laravel-11.x-red.svg?style=flat-square)](https://laravel.com/docs/11.x)
[![Laravel 12.x](https://img.shields.io/badge/Laravel-12.x-red.svg?style=flat-square)](https://laravel.com/docs/12.x)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/ageekdev/laravel-social-link-validator/run-tests.yml?label=tests&style=flat-square)](https://github.com/ageekdev/laravel-social-link-validator/actions/workflows/run-tests.yml)
[![Total Downloads](https://img.shields.io/packagist/dt/ageekdev/laravel-social-link-validator.svg?style=flat-square)](https://packagist.org/packages/ageekdev/laravel-social-link-validator)

Expand Down
21 changes: 10 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@
}
],
"require": {
"php": "^8.0",
"illuminate/support": "^9.0|^10.0|^11.0"
"php": "^8.1",
"illuminate/support": "^10.0|^11.0|^12.0"
},
"require-dev": {
"laravel/pint": "^1.10",
"nunomaduro/collision": "^6.0|^7.0|^8.0",
"nunomaduro/larastan": "^2.0",
"orchestra/testbench": "^7.0|^8.0",
"pestphp/pest": "^1.0|^2.0",
"pestphp/pest-plugin-laravel": "^1.4|^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"laravel/pint": "^1.5",
"larastan/larastan": "^2.0|^3.0",
"orchestra/testbench": "^8.11|^9.0|^10.0",
"pestphp/pest": "^2.0|^3.0",
"pestphp/pest-plugin-laravel": "^2.0|^3.0",
"phpstan/extension-installer": "^1.1|^2.0",
"phpstan/phpstan-deprecation-rules": "^1.0|^2.0",
"phpstan/phpstan-phpunit": "^1.0|^2.0",
"roave/security-advisories": "dev-latest"
},
"autoload": {
Expand Down
Empty file removed phpstan-baseline.neon
Empty file.
6 changes: 0 additions & 6 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
includes:
- phpstan-baseline.neon

parameters:
level: 4
paths:
Expand All @@ -10,9 +7,6 @@ parameters:
-
message: '#implements deprecated interface#'
path: src/Rules/SocialLink.php

tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
checkMissingIterableValueType: false

3 changes: 1 addition & 2 deletions src/Rules/SocialLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class SocialLink implements Rule
{
public function __construct(
protected array $parameters
) {
}
) {}

public function passes($attribute, $value): bool
{
Expand Down
6 changes: 3 additions & 3 deletions src/SocialLinkValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SocialLinkValidator
/**
* Validator constructor.
*/
public function __construct(array $drivers = null)
public function __construct(?array $drivers = null)
{
if (is_null($drivers)) {
$drivers = config('social-link-validator.platforms');
Expand All @@ -33,7 +33,7 @@ public function driver(string $driver): ValidatorInterface
}

if (empty($this->instances[$driver])) {
$this->instances[$driver] = new $this->drivers[$driver]();
$this->instances[$driver] = new $this->drivers[$driver];
}

return $this->instances[$driver];
Expand All @@ -43,7 +43,7 @@ public function guess(string $url): ?string
{
foreach ($this->drivers as $driver => $class) {
if (empty($this->instances[$driver])) {
$this->instances[$driver] = new $class();
$this->instances[$driver] = new $class;
}

if ($this->instances[$driver]->isValid($url)) {
Expand Down
2 changes: 1 addition & 1 deletion src/SocialLinkValidatorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function register(): void
$this->mergeConfigFrom(__DIR__.'/../config/social-link-validator.php', 'social-link-validator');

$this->app->singleton('laravel-social-link-validator', function ($app) {
return new SocialLinkValidator();
return new SocialLinkValidator;
});
}
}
2 changes: 1 addition & 1 deletion src/Validators/AbstractValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final public function isValid(string $url): bool

final public function split(string $url): LinkType
{
$result = new LinkType();
$result = new LinkType;
$patterns = $this->patterns;
$patternMaps = $this->patternMaps;

Expand Down
2 changes: 1 addition & 1 deletion src/Validators/LinkType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LinkType

public ?string $type = null;

public function __construct(bool $isValid = false, string $entityId = null, string $type = null)
public function __construct(bool $isValid = false, ?string $entityId = null, ?string $type = null)
{
$this->isValid = $isValid;
$this->id = $entityId;
Expand Down
4 changes: 2 additions & 2 deletions tests/SocialLinkValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
use AgeekDev\SocialLinkValidator\SocialLinkValidator;

it('should be valid platform', function ($name, $url) {
$validator = new SocialLinkValidator();
$validator = new SocialLinkValidator;
$result = $validator->guess($url);
expect($result)->toBe($name);
})->with('platforms');

it('should be valid platform by driver', function ($name, $url) {
$validator = new SocialLinkValidator();
$validator = new SocialLinkValidator;
$result = $validator->driver($name)->isValid($url);
expect($result)->toBeTrue();
})->with('platforms');