Skip to content

Commit

Permalink
Merge branch 'master' of github.com:beyondcode/laravel-favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed Jan 29, 2019
2 parents bea2ac8 + b7d7cd5 commit a642a68
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 19 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions config/favicon.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,4 @@
*/
'generator' => \BeyondCode\LaravelFavicon\Generators\EnvironmentGenerator::class,


];
];
8 changes: 4 additions & 4 deletions src/Favicon.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
}
2 changes: 1 addition & 1 deletion src/FaviconServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function boot()
__DIR__.'/../config/favicon.php' => config_path('favicon.php'),
], 'config');
}

$this->registerRoutes();
}

Expand Down
12 changes: 6 additions & 6 deletions src/Generators/EnvironmentGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
Expand All @@ -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');

Expand Down Expand Up @@ -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();
}
Expand All @@ -97,4 +97,4 @@ public function shouldGenerateFavicon(): bool
{
return config('favicon.enabled_environments.'.$this->environment) !== null;
}
}
}
2 changes: 1 addition & 1 deletion src/Generators/FaviconGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ interface FaviconGenerator
public function generate(string $icon): Response;

public function shouldGenerateFavicon(): bool;
}
}
2 changes: 1 addition & 1 deletion src/Http/Controllers/FaviconController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ public function __invoke(Request $request, FaviconGenerator $generator)
{
return $generator->generate($request->route('icon'));
}
}
}
2 changes: 1 addition & 1 deletion src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions tests/EnvironmentGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 0 additions & 1 deletion tests/FaviconTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace BeyondCode\LaravelFavicon\Tests;


use BeyondCode\LaravelFavicon\Favicon;
use BeyondCode\LaravelFavicon\FaviconServiceProvider;

Expand Down

0 comments on commit a642a68

Please sign in to comment.