Skip to content

Commit

Permalink
Merge pull request #3 from laravolt/analysis-8KV1ez
Browse files Browse the repository at this point in the history
Applied fixes from StyleCI
  • Loading branch information
uyab committed Dec 25, 2015
2 parents 1a18af8 + f414486 commit cd73732
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
6 changes: 3 additions & 3 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// List of foreground colors to be used, randomly selected based on name supplied
'foregrounds' => [
'#FFFFFF'
'#FFFFFF',
],

// List of background colors to be used, randomly selected based on name supplied
Expand Down Expand Up @@ -56,6 +56,6 @@
// 'foreground' (same as foreground color)
// 'background' (same as background color)
// or any valid hex ('#aabbcc')
'color' => 'foreground'
]
'color' => 'foreground',
],
];
17 changes: 9 additions & 8 deletions src/Avatar.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

namespace Laravolt\Avatar;

use Stringy\Stringy;
use Illuminate\Support\Arr;
use Illuminate\Cache\CacheManager;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Intervention\Image\Facades\Image;
use Stringy\Stringy;

class Avatar
{
Expand All @@ -31,7 +32,8 @@ class Avatar

/**
* Avatar constructor.
* @param array $config
*
* @param array $config
* @param CacheManager $cache
*/
public function __construct(array $config, CacheManager $cache)
Expand Down Expand Up @@ -88,6 +90,7 @@ public function toBase64()
public function save($path, $quality = 90)
{
$this->buildAvatar();

return $this->image->save($path, $quality);
}

Expand Down Expand Up @@ -201,7 +204,7 @@ protected function setFont()
if ($initials) {
$number = ord($initials[0]);
$font = $this->fonts[$number % count($this->fonts)];
$fontFile = base_path('resources/laravolt/avatar/fonts/' . $font);
$fontFile = base_path('resources/laravolt/avatar/fonts/'.$font);
if (is_file($fontFile)) {
$this->font = $fontFile;

Expand Down Expand Up @@ -240,12 +243,11 @@ protected function buildAvatar()
$font->align('center');
$font->valign('middle');
});

}

protected function createShape()
{
$method = 'create' . ucfirst($this->shape) . 'Shape';
$method = 'create'.ucfirst($this->shape).'Shape';
if (method_exists($this, $method)) {
return $this->$method();
}
Expand Down Expand Up @@ -288,13 +290,12 @@ protected function cacheKey()
'width',
'height',
'borderSize',
'borderColor'
'borderColor',
];
foreach ($attributes as $attr) {
$keys[] = $this->$attr;
}

return md5(implode('-', $keys));

}
}
3 changes: 2 additions & 1 deletion src/Facade.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

namespace Laravolt\Avatar;

class Facade extends \Illuminate\Support\Facades\Facade
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
protected static function getFacadeAccessor()
{
Expand Down
22 changes: 14 additions & 8 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
use Illuminate\Support\ServiceProvider as BaseServiceProvider;

/**
* Class PackageServiceProvider
* Class PackageServiceProvider.
*
* @package Laravolt\Avatar
* @see http://laravel.com/docs/5.1/packages#service-providers
* @see http://laravel.com/docs/5.1/providers
*/
Expand All @@ -17,6 +16,7 @@ class ServiceProvider extends BaseServiceProvider
* Indicates if loading of the provider is deferred.
*
* @see http://laravel.com/docs/5.1/providers#deferred-providers
*
* @var bool
*/
protected $defer = false;
Expand All @@ -25,21 +25,24 @@ class ServiceProvider extends BaseServiceProvider
* Register the service provider.
*
* @see http://laravel.com/docs/5.1/providers#the-register-method
*
* @return void
*/
public function register()
{
$this->app->bind('avatar',function($app){
$this->app->bind('avatar', function ($app) {
$config = $app->make('config');
$cache = $app->make('cache');

return new Avatar($config->get('avatar'), $cache);
});
}

/**
* Application is booting
* Application is booting.
*
* @see http://laravel.com/docs/5.1/providers#the-boot-method
*
* @return void
*/
public function boot()
Expand All @@ -49,9 +52,10 @@ public function boot()
}

/**
* Register the package public assets
* Register the package public assets.
*
* @see http://laravel.com/docs/5.1/packages#public-assets
*
* @return void
*/
protected function registerAssets()
Expand All @@ -62,9 +66,10 @@ protected function registerAssets()
}

/**
* Register the package configurations
* Register the package configurations.
*
* @see http://laravel.com/docs/5.1/packages#configuration
*
* @return void
*/
protected function registerConfigurations()
Expand All @@ -78,13 +83,14 @@ protected function registerConfigurations()
}

/**
* Loads a path relative to the package base directory
* Loads a path relative to the package base directory.
*
* @param string $path
*
* @return string
*/
protected function packagePath($path = '')
{
return sprintf("%s/../%s", __DIR__ , $path);
return sprintf('%s/../%s', __DIR__, $path);
}
}

0 comments on commit cd73732

Please sign in to comment.