Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.0 #20

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
32aa8cc
Update .gitignore
dsbilling Dec 29, 2023
37147b0
Added dependabot
dsbilling Dec 29, 2023
c3588d4
Updated core files
dsbilling Dec 29, 2023
f84306c
Create release.yml
dsbilling Dec 29, 2023
fdbf12c
Improved readme
dsbilling Dec 29, 2023
da2435b
Added compatibility table
dsbilling Dec 29, 2023
2e90e22
Drop older laravel versions and bump packages
dsbilling Dec 29, 2023
efaf205
Added php cs fixer
dsbilling Dec 29, 2023
dea3723
Update composer.json
dsbilling Dec 29, 2023
b046fff
Added typehinting
dsbilling Dec 29, 2023
de7c9a4
Add Pest dependencies
laravel-shift Dec 29, 2023
fe6ecc2
Add base Pest file
laravel-shift Dec 29, 2023
56fec8b
Convert test cases
laravel-shift Dec 29, 2023
d10454e
Adopt expectation API
laravel-shift Dec 29, 2023
596eb30
Optimize uses
laravel-shift Dec 29, 2023
e7045ad
Use Pest test runner
laravel-shift Dec 29, 2023
1ea7723
Remove PHP 8.0 support
dsbilling Dec 29, 2023
354456b
Delete .travis.yml
dsbilling Dec 29, 2023
6836904
Updated coverage command
dsbilling Dec 29, 2023
b5ace8f
Converted expect into chain
dsbilling Dec 29, 2023
c79527d
Update composer.json
dsbilling Dec 29, 2023
91b75dd
Merge pull request #1 from dsbilling/shift-107205
dsbilling Dec 29, 2023
5c76405
Create phpstan.yml
dsbilling Dec 29, 2023
2289ee7
Create run-tests.yml
dsbilling Dec 29, 2023
840dcc8
Delete .scrutinizer.yml
dsbilling Dec 29, 2023
370875f
Delete .styleci.yml
dsbilling Dec 29, 2023
bd11998
Update composer.json
dsbilling Dec 29, 2023
a8e92b7
Merge branch 'master' into release-2.0
dsbilling May 21, 2024
512cb95
Update run-tests.yml
dsbilling May 21, 2024
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ trim_trailing_whitespace = true
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
indent_size = 2
23 changes: 23 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check & fix styling

on: [push]

jobs:
php-cs-fixer:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs.dist.php --allow-risky=yes

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Fix styling
26 changes: 26 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PHPStan

on:
push:
paths:
- '**.php'
- 'phpstan.neon.dist'

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v2

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
45 changes: 45 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tests

on: [pull_request]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.2, 8.3]
laravel: [10.*, 11.*]
stability: [prefer-stable]
include:
- laravel: 10.*
testbench: ^8.0
- laravel: 11.*
testbench: ^9.0

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

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

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

- name: Execute tests
run: vendor/bin/pest
40 changes: 40 additions & 0 deletions .php_cs.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

$finder = Symfony\Component\Finder\Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method' => 'one',
],
],
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
])
->setFinder($finder);
19 changes: 0 additions & 19 deletions .scrutinizer.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .styleci.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ You can completely customize which environments you want to have enabled for the

To modify the default values, publish the package configuration file using:

```
```bash
php artisan vendor:publish --provider='BeyondCode\LaravelFavicon\FaviconServiceProvider' --tag='config'
```

Expand Down
34 changes: 23 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@
}
],
"require": {
"php": "^7.1|^8.0|^8.1|^8.2|^8.3",
"illuminate/http": "5.6.*|5.7.*|5.8.*|6.*|7.*|8.*|9.*|^10.0|^11.0",
"illuminate/support": "5.6.*|5.7.*|5.8.*|6.*|7.*|8.*|9.*|^10.0|^11.0",
"intervention/image": "^2.4"
"php": "^8.1|^8.2|^8.3",
"illuminate/http": "^9.0|^10.0|^11.0",
"illuminate/support": "^9.0|^10.0|^11.0",
"intervention/image": "^2.6"
},
"require-dev": {
"phpunit/phpunit": "^7.0|^8.0|^9.0|^10.0|^11.0",
"orchestra/testbench": "^3.7|^4.0|^5.0|^6.0|^7.0|^8.0|^9.0"
"nunomaduro/collision": "^7.0",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^8.0|^9.0",
"pestphp/pest": "^2.2",
"pestphp/pest-plugin-laravel": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^10.0|^11.0"
},
"autoload": {
"psr-4": {
Expand All @@ -39,18 +46,23 @@
}
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"

"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage"
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
}
},
"extra": {
"laravel": {
"providers": [
"BeyondCode\\LaravelFavicon\\FaviconServiceProvider"
]
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
9 changes: 4 additions & 5 deletions src/Favicon.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,24 @@

class Favicon
{
/** @var array */
protected $config;
protected array $config;

public function __construct(array $config)
{
$this->config = $config;
}

public function getFaviconText(string $environment)
public function getFaviconText(string $environment): mixed
{
return Arr::get($this->config, 'enabled_environments.'.$environment.'.text');
}

public function getFaviconColor(string $environment)
public function getFaviconColor(string $environment): mixed
{
return Arr::get($this->config, 'enabled_environments.'.$environment.'.color');
}

public function getFaviconBackgroundColor(string $environment)
public function getFaviconBackgroundColor(string $environment): mixed
{
return Arr::get($this->config, 'enabled_environments.'.$environment.'.background_color');
}
Expand Down
6 changes: 3 additions & 3 deletions src/FaviconServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FaviconServiceProvider extends ServiceProvider
/**
* Bootstrap the application services.
*/
public function boot()
public function boot(): void
{
if ($this->app->runningInConsole()) {
$this->publishes([
Expand All @@ -26,7 +26,7 @@ public function boot()
/**
* Register the application services.
*/
public function register()
public function register(): void
{
$this->mergeConfigFrom(__DIR__.'/../config/favicon.php', 'favicon');

Expand All @@ -39,7 +39,7 @@ public function register()
});
}

protected function registerRoutes()
protected function registerRoutes(): void
{
Route::get(config('favicon.url_prefix').'/{icon}', FaviconController::class)
->where('icon', '.*');
Expand Down
11 changes: 4 additions & 7 deletions src/Generators/EnvironmentGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@

class EnvironmentGenerator implements FaviconGenerator
{
/** @var Favicon */
protected $favicon;
protected Favicon $favicon;

/** @var ImageManager */
protected $manager;
protected ImageManager $manager;

/** @var string */
protected $environment;
protected string $environment;

public function __construct(Favicon $favicon)
{
Expand Down Expand Up @@ -82,7 +79,7 @@ protected function calculateDynamicFontSize(AbstractFont $font, Image $icon, $pa
}
}

protected function createEnvironmentTextImage(AbstractFont $font)
protected function createEnvironmentTextImage(AbstractFont $font): Image
{
$size = $font->getBoxSize();

Expand Down
3 changes: 2 additions & 1 deletion src/Http/Controllers/FaviconController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

use BeyondCode\LaravelFavicon\Generators\FaviconGenerator;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class FaviconController
{
public function __invoke(Request $request, FaviconGenerator $generator)
public function __invoke(Request $request, FaviconGenerator $generator): Response
{
return $generator->generate($request->route('icon'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use BeyondCode\LaravelFavicon\Generators\FaviconGenerator;

if (! function_exists('favicon')) {
function favicon($image)
function favicon(string $image): string
{
if (app(FaviconGenerator::class)->shouldGenerateFavicon(app()->environment())) {
return rtrim(config('app.url'), '/').'/'.config('favicon.url_prefix')."/$image";
Expand Down
Loading
Loading