Skip to content

Commit 20f9a7a

Browse files
Merge pull request #16 from ARCANEDEV/update-package
Updating the package
2 parents 562f658 + 0d7285c commit 20f9a7a

File tree

8 files changed

+56
-71
lines changed

8 files changed

+56
-71
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Gravatar [![Packagist License][badge_license]](LICENSE.md) [![For PHP][badge_php]][link-github-repo]
1+
# Gravatar [![Packagist License][badge_license]](LICENSE.md) [![For PHP][badge_php]][link-github-repo] [![Laravel 5 Supported][badge_laravel]][link-github-repo]
22

33
[![Travis Status][badge_build]][link-travis]
44
[![Coverage Status][badge_coverage]][link-scrutinizer]
@@ -7,7 +7,6 @@
77
[![Github Issues][badge_issues]][link-github-issues]
88

99
[![Packagist][badge_package]][link-packagist]
10-
[![Laravel 5 Supported][badge_laravel]][link-github-repo]
1110
[![Packagist Release][badge_release]][link-packagist]
1211
[![Packagist Downloads][badge_downloads]][link-packagist]
1312

@@ -20,7 +19,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/Gravatar/rele
2019
### Features
2120

2221
* Framework-agnostic package.
23-
* Laravel `5.0` to `6.0` are Supported.
22+
* Laravel `5.x | 6.x` are Supported.
2423
* Easy setup & configuration.
2524
* Well tested (100% code coverage with maximum code quality).
2625
* Made with :heart: & :coffee:.
@@ -48,7 +47,7 @@ Any ideas are welcome. Feel free to submit any issues or pull requests, please c
4847
[badge_insight]: https://img.shields.io/sensiolabs/i/b295ae87-bc10-4a43-9ca4-fbeab5c7fcda.svg?style=flat-square
4948
[badge_issues]: http://img.shields.io/github/issues/ARCANEDEV/Gravatar.svg?style=flat-square
5049
[badge_package]: https://img.shields.io/badge/package-arcanedev/gravatar-blue.svg?style=flat-square
51-
[badge_laravel]: https://img.shields.io/badge/Laravel%20Supported-5.x%20&%206.0-orange.svg?style=flat-square
50+
[badge_laravel]: https://img.shields.io/badge/Laravel%20Supported-5.x%20|%206.x-orange.svg?style=flat-square
5251
[badge_release]: https://img.shields.io/packagist/v/arcanedev/gravatar.svg?style=flat-square
5352
[badge_downloads]: https://img.shields.io/packagist/dt/arcanedev/gravatar.svg?style=flat-square
5453

_docs/0-Home.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/Gravatar/rele
77
### Features
88

99
* Framework-agnostic package.
10-
* Laravel `5.0` to `6.0` are Supported.
10+
* Laravel `5.x | 6.x` are Supported.
1111
* Easy setup & configuration.
1212
* Well tested (100% code coverage with maximum code quality).
1313
* Made with :heart: & :coffee:.
1414

1515
## Table of contents
1616

17-
1. [Requirements](1-Requirements.md)
18-
2. [Installation and Setup](2-Installation-and-Setup.md)
19-
3. [Configuration](3-Configuration.md)
20-
4. [Usage](4-Usage.md)
17+
1. [Installation and Setup](1-Installation-and-Setup.md)
18+
2. [Configuration](2-Configuration.md)
19+
3. [Usage](3-Usage.md)

_docs/1-Installation-and-Setup.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
| ![Gravatar v2.2.x][gravatar_2_2] | ![Laravel v5.6][laravel_5_6] |
1717
| ![Gravatar v2.3.x][gravatar_2_3] | ![Laravel v5.7][laravel_5_7] |
1818
| ![Gravatar v2.4.x][gravatar_2_4] | ![Laravel v5.8][laravel_5_8] |
19-
| ![Gravatar v3.0.x][gravatar_3_0] | ![Laravel v6.0][laravel_6_0] |
19+
| ![Gravatar v3.0.x][gravatar_3_x] | ![Laravel v6.0][laravel_6_x] |
2020

2121
> **Note :** This is a framework-agnostic package, so you can use any version of this package in your PHP project.
2222
@@ -29,15 +29,15 @@
2929
[laravel_5_6]: https://img.shields.io/badge/v5.6-supported-brightgreen.svg?style=flat-square "Laravel v5.6"
3030
[laravel_5_7]: https://img.shields.io/badge/v5.7-supported-brightgreen.svg?style=flat-square "Laravel v5.7"
3131
[laravel_5_8]: https://img.shields.io/badge/v5.8-supported-brightgreen.svg?style=flat-square "Laravel v5.8"
32-
[laravel_6_0]: https://img.shields.io/badge/v6.0-supported-brightgreen.svg?style=flat-square "Laravel v6.0"
32+
[laravel_6_x]: https://img.shields.io/badge/v6.x-supported-brightgreen.svg?style=flat-square "Laravel v6.x"
3333

34-
[gravatar_1_x]: https://img.shields.io/badge/version-1.*-blue.svg?style=flat-square "Gravatar v1.*"
35-
[gravatar_2_0]: https://img.shields.io/badge/version-2.0.*-blue.svg?style=flat-square "Gravatar v2.0.*"
36-
[gravatar_2_1]: https://img.shields.io/badge/version-2.1.*-blue.svg?style=flat-square "Gravatar v2.1.*"
37-
[gravatar_2_2]: https://img.shields.io/badge/version-2.2.*-blue.svg?style=flat-square "Gravatar v2.2.*"
38-
[gravatar_2_3]: https://img.shields.io/badge/version-2.3.*-blue.svg?style=flat-square "Gravatar v2.3.*"
39-
[gravatar_2_4]: https://img.shields.io/badge/version-2.4.*-blue.svg?style=flat-square "Gravatar v2.4.*"
40-
[gravatar_3_0]: https://img.shields.io/badge/version-3.0.*-blue.svg?style=flat-square "Gravatar v3.0.*"
34+
[gravatar_1_x]: https://img.shields.io/badge/version-1.x-blue.svg?style=flat-square "Gravatar v1.x"
35+
[gravatar_2_0]: https://img.shields.io/badge/version-2.0.x-blue.svg?style=flat-square "Gravatar v2.0.x"
36+
[gravatar_2_1]: https://img.shields.io/badge/version-2.1.x-blue.svg?style=flat-square "Gravatar v2.1.x"
37+
[gravatar_2_2]: https://img.shields.io/badge/version-2.2.x-blue.svg?style=flat-square "Gravatar v2.2.x"
38+
[gravatar_2_3]: https://img.shields.io/badge/version-2.3.x-blue.svg?style=flat-square "Gravatar v2.3.x"
39+
[gravatar_2_4]: https://img.shields.io/badge/version-2.4.x-blue.svg?style=flat-square "Gravatar v2.4.x"
40+
[gravatar_3_x]: https://img.shields.io/badge/version-3.x-blue.svg?style=flat-square "Gravatar v3.x"
4141

4242
## Composer
4343

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
"require": {
1919
"php" : ">=7.2.0",
2020
"ext-curl": "*",
21-
"arcanedev/support": "~5.0.0",
22-
"arcanedev/php-html": "~3.0"
21+
"arcanedev/support": "^5.0",
22+
"arcanedev/php-html": "^3.0"
2323
},
2424
"require-dev": {
25-
"orchestra/testbench": "~4.0.0",
26-
"phpunit/phpcov": "~6.0",
27-
"phpunit/phpunit": "~8.0"
25+
"orchestra/testbench": "^4.0",
26+
"phpunit/phpcov": "^6.0",
27+
"phpunit/phpunit": "^8.0"
2828
},
2929
"autoload": {
3030
"psr-4": {

helpers.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

3+
use Arcanedev\Gravatar\Contracts\Gravatar;
4+
35
if ( ! function_exists('gravatar')) {
46
/**
57
* Get the gravatar instance.
68
*
79
* @return Arcanedev\Gravatar\Contracts\Gravatar
810
*/
9-
function gravatar()
11+
function gravatar(): Gravatar
1012
{
11-
return app(Arcanedev\Gravatar\Contracts\Gravatar::class);
13+
return app(Gravatar::class);
1214
}
1315
}

src/Gravatar.php

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -347,29 +347,6 @@ public function exists($email)
347347
return strpos($headers[0], '200') ? true : false;
348348
}
349349

350-
/* -----------------------------------------------------------------
351-
| Check Methods
352-
| -----------------------------------------------------------------
353-
*/
354-
355-
/**
356-
* Check image url.
357-
*
358-
* @param string $image
359-
*
360-
* @return string
361-
*
362-
* @throws \Arcanedev\Gravatar\Exceptions\InvalidImageUrlException
363-
*/
364-
private function checkImageUrl($image)
365-
{
366-
if ( ! filter_var($image, FILTER_VALIDATE_URL)) {
367-
throw Exceptions\InvalidImageUrlException::make($image);
368-
}
369-
370-
return $image;
371-
}
372-
373350
/* -----------------------------------------------------------------
374351
| Other Methods
375352
| -----------------------------------------------------------------
@@ -382,7 +359,7 @@ private function checkImageUrl($image)
382359
*
383360
* @return array
384361
*/
385-
private function getParams($email)
362+
private function getParams(string $email): array
386363
{
387364
$params = $this->cachedParams;
388365

@@ -404,6 +381,24 @@ private function getParams($email)
404381
return (array) $params;
405382
}
406383

384+
/**
385+
* Check image url.
386+
*
387+
* @param string $image
388+
*
389+
* @return string
390+
*
391+
* @throws \Arcanedev\Gravatar\Exceptions\InvalidImageUrlException
392+
*/
393+
private function checkImageUrl(string $image)
394+
{
395+
if ( ! filter_var($image, FILTER_VALIDATE_URL)) {
396+
throw Exceptions\InvalidImageUrlException::make($image);
397+
}
398+
399+
return $image;
400+
}
401+
407402
/**
408403
* Check the image size.
409404
*

src/GravatarServiceProvider.php

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

3-
use Arcanedev\Support\PackageServiceProvider as ServiceProvider;
3+
use Arcanedev\Support\Providers\PackageServiceProvider;
4+
use Illuminate\Contracts\Support\DeferrableProvider;
45

56
/**
67
* Class GravatarServiceProvider
78
*
89
* @package Arcanedev\Gravatar
910
* @author ARCANEDEV <arcanedev.maroc@gmail.com>
1011
*/
11-
class GravatarServiceProvider extends ServiceProvider
12+
class GravatarServiceProvider extends PackageServiceProvider implements DeferrableProvider
1213
{
1314
/* -----------------------------------------------------------------
1415
| Properties
@@ -22,13 +23,6 @@ class GravatarServiceProvider extends ServiceProvider
2223
*/
2324
protected $package = 'gravatar';
2425

25-
/**
26-
* Indicates if loading of the provider is deferred.
27-
*
28-
* @var bool
29-
*/
30-
protected $defer = true;
31-
3226
/* -----------------------------------------------------------------
3327
| Main Methods
3428
| -----------------------------------------------------------------
@@ -37,31 +31,26 @@ class GravatarServiceProvider extends ServiceProvider
3731
/**
3832
* Register the service provider.
3933
*/
40-
public function register()
34+
public function register(): void
4135
{
4236
parent::register();
4337

4438
$this->registerConfig();
4539

4640
$this->singleton(Contracts\Gravatar::class, function($app) {
47-
/** @var \Illuminate\Contracts\Config\Repository $config */
48-
$config = $app['config'];
49-
5041
return new Gravatar(
51-
$config->get('gravatar.default', 'mm'),
52-
$config->get('gravatar.size', 80),
53-
$config->get('gravatar.max-rating', 'g')
42+
$app['config']->get('gravatar.default', 'mm'),
43+
$app['config']->get('gravatar.size', 80),
44+
$app['config']->get('gravatar.max-rating', 'g')
5445
);
5546
});
5647
}
5748

5849
/**
5950
* Boot the service provider.
6051
*/
61-
public function boot()
52+
public function boot(): void
6253
{
63-
parent::boot();
64-
6554
$this->publishConfig();
6655
}
6756

@@ -70,7 +59,7 @@ public function boot()
7059
*
7160
* @return array
7261
*/
73-
public function provides()
62+
public function provides(): array
7463
{
7564
return [
7665
Contracts\Gravatar::class,

tests/GravatarServiceProviderTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public function it_can_be_instantiated()
4747
{
4848
$expectations = [
4949
\Illuminate\Support\ServiceProvider::class,
50-
\Arcanedev\Support\ServiceProvider::class,
51-
\Arcanedev\Support\PackageServiceProvider::class,
50+
\Illuminate\Contracts\Support\DeferrableProvider::class,
51+
\Arcanedev\Support\Providers\ServiceProvider::class,
52+
\Arcanedev\Support\Providers\PackageServiceProvider::class,
5253
\Arcanedev\Gravatar\GravatarServiceProvider::class,
5354
];
5455

0 commit comments

Comments
 (0)