From 26dfefc5331ac5f395fcadbf1baee5a89ebd3d11 Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Tue, 29 Jan 2019 15:52:08 +0100 Subject: [PATCH 1/2] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index c2ff6b3..a914322 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,12 @@ Create dynamic favicons based on your environment settings. ![](https://beyondco.de/github/favicons/screenshot.png) +## Laravel Package Development + +[![https://phppackagedevelopment.com](https://beyondco.de/courses/phppd.jpg)](https://phppackagedevelopment.com) + +If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming [PHP Package Development](https://phppackagedevelopment.com) video course. + ## Installation You can install the package via composer: From b7d7cd50c62c0a1697e1f29789747559f3b5418e Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Tue, 29 Jan 2019 15:54:24 +0100 Subject: [PATCH 2/2] Apply fixes from StyleCI (#1) --- config/favicon.php | 3 +-- src/Favicon.php | 8 ++++---- src/FaviconServiceProvider.php | 2 +- src/Generators/EnvironmentGenerator.php | 12 ++++++------ src/Generators/FaviconGenerator.php | 2 +- src/Http/Controllers/FaviconController.php | 2 +- src/helpers.php | 2 +- tests/EnvironmentGeneratorTest.php | 2 -- tests/FaviconTest.php | 1 - 9 files changed, 15 insertions(+), 19 deletions(-) diff --git a/config/favicon.php b/config/favicon.php index c9f2db5..0eb0d79 100644 --- a/config/favicon.php +++ b/config/favicon.php @@ -56,5 +56,4 @@ */ 'generator' => \BeyondCode\LaravelFavicon\Generators\EnvironmentGenerator::class, - -]; \ No newline at end of file +]; diff --git a/src/Favicon.php b/src/Favicon.php index 2585f71..39cfdb2 100644 --- a/src/Favicon.php +++ b/src/Favicon.php @@ -14,16 +14,16 @@ public function __construct(array $config) public function getFaviconText(string $environment) { - return array_get($this->config,'enabled_environments.'.$environment.'.text'); + return array_get($this->config, 'enabled_environments.'.$environment.'.text'); } public function getFaviconColor(string $environment) { - return array_get($this->config,'enabled_environments.'.$environment.'.color'); + return array_get($this->config, 'enabled_environments.'.$environment.'.color'); } public function getFaviconBackgroundColor(string $environment) { - return array_get($this->config,'enabled_environments.'.$environment.'.background_color'); + return array_get($this->config, 'enabled_environments.'.$environment.'.background_color'); } -} \ No newline at end of file +} diff --git a/src/FaviconServiceProvider.php b/src/FaviconServiceProvider.php index 581acf8..6e72349 100644 --- a/src/FaviconServiceProvider.php +++ b/src/FaviconServiceProvider.php @@ -19,7 +19,7 @@ public function boot() __DIR__.'/../config/favicon.php' => config_path('favicon.php'), ], 'config'); } - + $this->registerRoutes(); } diff --git a/src/Generators/EnvironmentGenerator.php b/src/Generators/EnvironmentGenerator.php index e77fae7..1f05fe6 100644 --- a/src/Generators/EnvironmentGenerator.php +++ b/src/Generators/EnvironmentGenerator.php @@ -4,8 +4,8 @@ use Illuminate\Http\Response; use Intervention\Image\Image; -use Intervention\Image\ImageManager; use Intervention\Image\AbstractFont; +use Intervention\Image\ImageManager; use BeyondCode\LaravelFavicon\Favicon; use Intervention\Image\Gd\Font as GdFont; use Intervention\Image\Imagick\Font as ImagickFont; @@ -26,7 +26,7 @@ public function __construct(Favicon $favicon) $this->favicon = $favicon; $this->manager = new ImageManager([ - 'driver' => config('favicon.image_driver') + 'driver' => config('favicon.image_driver'), ]); $this->environment = config('app.env'); @@ -41,7 +41,7 @@ public function generate(string $icon): Response $font = $this->getFont($this->favicon->getFaviconText($this->environment)); - $font->file(config('favicon.font') ?? __DIR__ . '/../../resources/fonts/OpenSans-Regular.ttf'); + $font->file(config('favicon.font') ?? __DIR__.'/../../resources/fonts/OpenSans-Regular.ttf'); $font->valign('top'); @@ -73,10 +73,10 @@ protected function calculateDynamicFontSize(AbstractFont $font, Image $icon, $pa { $size = $font->getBoxSize(); - while ($size["width"] + $paddingX > $icon->width() && $font->getSize() > 0) { + while ($size['width'] + $paddingX > $icon->width() && $font->getSize() > 0) { $fontSize = $font->getSize(); - $font->size($fontSize-1); + $font->size($fontSize - 1); $size = $font->getBoxSize(); } @@ -97,4 +97,4 @@ public function shouldGenerateFavicon(): bool { return config('favicon.enabled_environments.'.$this->environment) !== null; } -} \ No newline at end of file +} diff --git a/src/Generators/FaviconGenerator.php b/src/Generators/FaviconGenerator.php index 364cb64..73a181e 100644 --- a/src/Generators/FaviconGenerator.php +++ b/src/Generators/FaviconGenerator.php @@ -9,4 +9,4 @@ interface FaviconGenerator public function generate(string $icon): Response; public function shouldGenerateFavicon(): bool; -} \ No newline at end of file +} diff --git a/src/Http/Controllers/FaviconController.php b/src/Http/Controllers/FaviconController.php index 18ef79a..a82604d 100644 --- a/src/Http/Controllers/FaviconController.php +++ b/src/Http/Controllers/FaviconController.php @@ -11,4 +11,4 @@ public function __invoke(Request $request, FaviconGenerator $generator) { return $generator->generate($request->route('icon')); } -} \ No newline at end of file +} diff --git a/src/helpers.php b/src/helpers.php index 370f9b0..5f2530d 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -6,7 +6,7 @@ function favicon($image) { if (app(FaviconGenerator::class)->shouldGenerateFavicon(app()->environment())) { - return "/".config('favicon.url_prefix')."/$image"; + return '/'.config('favicon.url_prefix')."/$image"; } return $image; diff --git a/tests/EnvironmentGeneratorTest.php b/tests/EnvironmentGeneratorTest.php index 1878d62..dfaea52 100644 --- a/tests/EnvironmentGeneratorTest.php +++ b/tests/EnvironmentGeneratorTest.php @@ -2,13 +2,11 @@ namespace BeyondCode\LaravelFavicon\Tests; - use BeyondCode\LaravelFavicon\Favicon; use BeyondCode\LaravelFavicon\FaviconServiceProvider; class EnvironmentGeneratorTest extends \Orchestra\Testbench\TestCase { - protected function getPackageProviders($app) { return [FaviconServiceProvider::class]; diff --git a/tests/FaviconTest.php b/tests/FaviconTest.php index 8b47461..733346f 100644 --- a/tests/FaviconTest.php +++ b/tests/FaviconTest.php @@ -2,7 +2,6 @@ namespace BeyondCode\LaravelFavicon\Tests; - use BeyondCode\LaravelFavicon\Favicon; use BeyondCode\LaravelFavicon\FaviconServiceProvider;