Skip to content

Commit

Permalink
Removed gravatar() and gravatar_profile() helpers functions
Browse files Browse the repository at this point in the history
  • Loading branch information
forxer committed Mar 16, 2023
1 parent 0afacae commit db07895
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 35 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
CHANGELOG
=========

4.0.0 (2023-03-16)
------------------

- Removed `gravatar()` and `gravatar_profile()` helpers functions
- Added documentation to implement own helpers


3.0.1 (2023-03-16)
------------------

- Added UPGRADE.md
- Improved README.md file
- Uppercased "README" and "CHANGELOG" files


3.0.0 (2023-03-16)
------------------

Expand Down
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Usage

There are many ways to use this library:

- Use helpers fonctions `gravatar()` and `gravatar_profile()`
- Use helpers fonctions
- Use the Gravatar base class with its `Gravatar::image()` and `Gravatar::profile()` methods
- Instantiate the dedicated classes `Gravatar\Image()` and `Gravatar\Profile()`

Expand All @@ -93,6 +93,45 @@ Whatever method you use, you could use the `url()` method to retrieve it. Or dis

The easiest way to use this library is to use the helper functions.

Since version 4, in order to avoid conflicts with other packages, we no longer define the `gravatar()` and `gravatar_profile()` helpers. It's up to you to do this in your app with names that work for you and don't conflict with others. Here's how to do it; it's simple.

In a file dedicated to the helper functions, define the version 3 functions using the names that suit you.

```php
<?php

use Gravatar\Image;
use Gravatar\Profile;

if (! function_exists('gravatar')) {
/**
* Return a new Gravatar Image instance.
*
* @param string|null $email
* @return Image
*/
function gravatar(?string $email = null): Image
{
return new Image($email);
}
}

if (! function_exists('gravatar_profile')) {
/**
* Return a new Gravatar Profile instance.
*
* @param string|null $email
* @return Profile
*/
function gravatar_profile(?string $email = null): Profile
{
return new Profile($email);
}
}
```

This way you can use them like this:

```php
<?php
require 'vendor/autoload.php';
Expand Down
10 changes: 10 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
UPGRADE
=======

From 3.x to 4.x
---------------

In version 3 I introduced 2 helpers `gravatar()` and `gravatar_profile()` but it was a bad idea.

The `gravatar()` and `gravatar_profile()` helpers have been removed from the package because they could conflict with other global functions of the same name.

I prefer to indicate how to define your own helpers rather than embedding them "hard" in the package.


From 2.x to 3.x
---------------

Expand Down
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
"autoload" : {
"psr-4" : {
"Gravatar\\" : "src"
},
"files": [
"src/helpers.php"
]
}
},
"minimum-stability" : "dev",
"support" : {
Expand Down
30 changes: 0 additions & 30 deletions src/helpers.php

This file was deleted.

0 comments on commit db07895

Please sign in to comment.