Skip to content

Commit 76697d2

Browse files
Merge pull request #1 from ARCANEDEV/develop
Updating the package
2 parents 0422b03 + 4904ddf commit 76697d2

15 files changed

+159
-86
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
end_of_line = lf
8+
charset = utf-8
9+
indent_style = space
10+
indent_size = 4
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true
13+
14+
[*.md]
15+
indent_size = 2

.scrutinizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ checks:
2121
tools:
2222
external_code_coverage:
2323
timeout: 600
24-
runs: 3
24+
runs: 12
2525
php_code_sniffer:
2626
enabled: true
2727
config:

.travis.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
language: php
22

3+
sudo: false
4+
35
php:
46
- 5.5.9
57
- 5.5
68
- 5.6
79
- 7.0
810
- hhvm
911

10-
sudo: false
12+
env:
13+
- TESTBENCH_VERSION=3.0.*
14+
- TESTBENCH_VERSION=3.1.*
15+
- TESTBENCH_VERSION=3.2.*
1116

1217
before_script:
1318
- travis_retry composer self-update
14-
- travis_retry composer install --prefer-source --no-interaction
19+
- travis_retry composer require --prefer-source --no-interaction --dev "orchestra/testbench:${TESTBENCH_VERSION}"
1520

1621
script:
1722
- composer validate
1823
- mkdir -p build/logs
1924
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
2025

2126
after_script:
22-
- if [ "$TRAVIS_PHP_VERSION" != "7.0" ] && [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
23-
- if [ "$TRAVIS_PHP_VERSION" != "7.0" ] && [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
27+
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
28+
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 ARCANEDEV - Gravatar
3+
Copyright (c) 2015-2016 | ARCANEDEV - Gravatar
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
Gravatar is a small library that provides an easy way to integrate and generate … Gravatars ??
3333

3434
Feel free to check out the [releases](https://github.com/ARCANEDEV/Gravatar/releases), [license](LICENSE.md), and [contribution guidelines](CONTRIBUTING.md).
35-
35+
3636
### Features
3737

3838
* Framework-agnostic (Works in any PHP projects).
39-
* Laravel 5 Supported.
40-
* Easy setup & configuration.
39+
* Laravel 5.0, 5.1 & 5.2 are Supported.
40+
* Easy setup & configuration.
4141
* Well tested (100% code coverage with maximum code quality).
4242
* Made with :heart: & :coffee:.
4343

composer.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
{
22
"name": "arcanedev/gravatar",
3-
"description": "Gravatar Package for Laravel",
4-
"keywords": ["arcanedev", "gravatar", "avatar", "identicon", "monsterid", "wavatar", "retro", "laravel"],
3+
"description": "A library providing easy gravatar integration/generation (Laravel supported).",
4+
"keywords": [
5+
"arcanedev", "gravatar", "avatar", "identicon", "monsterid", "wavatar", "retro", "laravel"
6+
],
57
"homepage": "https://github.com/ARCANEDEV/Gravatar",
68
"authors": [
79
{
810
"name": "ARCANEDEV",
911
"email": "arcanedev.maroc@gmail.com",
10-
"homepage": "https://github.com/ARCANEDEV",
12+
"homepage": "https://github.com/arcanedev-maroc",
1113
"role": "Developer"
1214
}
1315
],
1416
"type": "library",
1517
"license": "MIT",
1618
"require": {
17-
"php" : ">=5.5.9",
18-
"arcanedev/support": "~3.0"
19+
"php" : ">=5.5.9",
20+
"arcanedev/support": "~3.0"
1921
},
2022
"require-dev": {
21-
"orchestra/testbench": "~3.1",
22-
"phpunit/phpunit": "~4.0|~5.0",
23-
"phpunit/phpcov": "~2.0"
23+
"phpunit/phpcov": "~2.0|~3.0",
24+
"phpunit/phpunit": "~4.0|~5.0"
2425
},
2526
"autoload": {
2627
"psr-4": {
@@ -33,6 +34,9 @@
3334
"Arcanedev\\Gravatar\\Tests\\": "tests/"
3435
}
3536
},
37+
"scripts": {
38+
"testbench": "composer require --dev \"orchestra/testbench=~3.0\""
39+
},
3640
"extra": {
3741
"branch-alias": {
3842
"dev-master": "2.0-dev"

helpers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
/**
55
* Get the gravatar instance.
66
*
7-
* @return \Arcanedev\Gravatar\Gravatar
7+
* @return Arcanedev\Gravatar\Contracts\Gravatar
88
*/
99
function gravatar()
1010
{
11-
return app('arcanedev.gravatar');
11+
return app(Arcanedev\Gravatar\Contracts\Gravatar::class);
1212
}
1313
}
1414

src/Contracts/GravatarInterface.php renamed to src/Contracts/Gravatar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php namespace Arcanedev\Gravatar\Contracts;
22

33
/**
4-
* Interface GravatarInterface
4+
* Interface Gravatar
55
*
66
* @package Arcanedev\Gravatar\Contracts
77
* @author ARCANEDEV <arcanedev.maroc@gmail.com>
88
*/
9-
interface GravatarInterface
9+
interface Gravatar
1010
{
1111
/* ------------------------------------------------------------------------------------------------
1212
| Getters & Setters

src/Gravatar.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php namespace Arcanedev\Gravatar;
22

3-
use Arcanedev\Gravatar\Contracts\GravatarInterface;
4-
use Arcanedev\Gravatar\Exceptions\InvalidImageRatingException;
5-
use Arcanedev\Gravatar\Exceptions\InvalidImageSizeException;
6-
use Arcanedev\Gravatar\Exceptions\InvalidImageUrlException;
73
use Arcanedev\Gravatar\Helpers\HtmlBuilder;
84

95
/**
@@ -12,7 +8,7 @@
128
* @package Arcanedev\Gravatar
139
* @author ARCANEDEV <arcanedev.maroc@gmail.com>
1410
*/
15-
class Gravatar implements GravatarInterface
11+
class Gravatar implements Contracts\Gravatar
1612
{
1713
/* ------------------------------------------------------------------------------------------------
1814
| Constants
@@ -30,35 +26,35 @@ class Gravatar implements GravatarInterface
3026
*
3127
* @var mixed
3228
*/
33-
protected $defaultImage = false;
29+
protected $defaultImage = false;
3430

3531
/**
3632
* The maximum rating to allow for the avatar.
3733
*
3834
* @var string
3935
*/
40-
protected $rating = 'g';
36+
protected $rating = 'g';
4137

4238
/**
4339
* The avatar size.
4440
*
4541
* @var int
4642
*/
47-
protected $size = 80;
43+
protected $size = 80;
4844

4945
/**
5046
* Should we use the secure (HTTPS) URL base ?
5147
*
5248
* @var bool
5349
*/
54-
protected $secure = false;
50+
protected $secure = false;
5551

5652
/**
5753
* A temporary internal cache of the URL parameters.
5854
*
5955
* @var string
6056
*/
61-
protected $cachedParams = null;
57+
protected $cachedParams = null;
6258

6359
/**
6460
* Supported image defaults.
@@ -172,15 +168,15 @@ public function setSize($size)
172168
$this->cachedParams = null;
173169

174170
if ( ! is_val_integer($size)) {
175-
throw new InvalidImageSizeException(
171+
throw new Exceptions\InvalidImageSizeException(
176172
'Avatar size specified must be an integer.'
177173
);
178174
}
179175

180176
$size = (int) $size;
181177

182178
if (is_int_not_between($size, 0, 512)) {
183-
throw new InvalidImageSizeException(
179+
throw new Exceptions\InvalidImageSizeException(
184180
'Avatar size must be within 0 pixels and 512 pixels.'
185181
);
186182
}
@@ -216,7 +212,7 @@ public function setRating($rating)
216212
$rating = strtolower($rating);
217213

218214
if ( ! in_array($rating, $this->supportedRatings)) {
219-
throw new InvalidImageRatingException(
215+
throw new Exceptions\InvalidImageRatingException(
220216
"Invalid rating '$rating' specified, only 'g', 'pg', 'r' or 'x' are supported."
221217
);
222218
}
@@ -377,7 +373,7 @@ public function hashEmail($email)
377373
private function checkImageUrl($image)
378374
{
379375
if ( ! filter_var($image, FILTER_VALIDATE_URL)) {
380-
throw new InvalidImageUrlException(
376+
throw new Exceptions\InvalidImageUrlException(
381377
'The default image specified is not a recognized gravatar "default" and is not a valid URL'
382378
);
383379
}

src/GravatarServiceProvider.php

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,21 @@ class GravatarServiceProvider extends ServiceProvider
1919
*
2020
* @var string
2121
*/
22-
protected $vendor = 'arcanedev';
22+
protected $vendor = 'arcanedev';
2323

2424
/**
2525
* Package name.
2626
*
2727
* @var string
2828
*/
29-
protected $package = 'gravatar';
29+
protected $package = 'gravatar';
30+
31+
/**
32+
* Indicates if loading of the provider is deferred.
33+
*
34+
* @var bool
35+
*/
36+
protected $defer = true;
3037

3138
/* ------------------------------------------------------------------------------------------------
3239
| Getters & Setters
@@ -48,8 +55,6 @@ public function getBasePath()
4855
*/
4956
/**
5057
* Register the service provider.
51-
*
52-
* @return void
5358
*/
5459
public function register()
5560
{
@@ -59,13 +64,9 @@ public function register()
5964

6065
/**
6166
* Boot the service provider.
62-
*
63-
* @return void
6467
*/
6568
public function boot()
6669
{
67-
parent::boot();
68-
6970
$this->publishConfig();
7071
}
7172

@@ -76,29 +77,22 @@ public function boot()
7677
*/
7778
public function provides()
7879
{
79-
return ['arcanedev.gravatar'];
80+
return [
81+
'arcanedev.gravatar',
82+
Contracts\Gravatar::class,
83+
];
8084
}
8185

8286
/* ------------------------------------------------------------------------------------------------
8387
| Other Functions
8488
| ------------------------------------------------------------------------------------------------
8589
*/
86-
/**
87-
* Publishes configs.
88-
*/
89-
private function publishConfig()
90-
{
91-
$this->publishes([
92-
$this->getConfigFile() => config_path("{$this->package}.php"),
93-
], 'config');
94-
}
95-
9690
/**
9791
* Register Gravatar Helper.
9892
*/
9993
private function registerGravatar()
10094
{
101-
$this->app->singleton('arcanedev.gravatar', function($app) {
95+
$this->singleton('arcanedev.gravatar', function($app) {
10296
/** @var \Illuminate\Config\Repository $config */
10397
$config = $app['config'];
10498

@@ -108,5 +102,17 @@ private function registerGravatar()
108102
$config->get('gravatar.max-rating', 'g')
109103
);
110104
});
105+
106+
$this->bind(Contracts\Gravatar::class, 'arcanedev.gravatar');
107+
}
108+
109+
/**
110+
* Publishes configs.
111+
*/
112+
private function publishConfig()
113+
{
114+
$this->publishes([
115+
$this->getConfigFile() => config_path("{$this->package}.php"),
116+
], 'config');
111117
}
112118
}

0 commit comments

Comments
 (0)