GravatarHelper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getGravatarUrl() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula - https://ziku.la/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Zikula\UsersBundle\Helper;
15
16
class GravatarHelper
17
{
18
    /**
19
     * Returns the URL to a gravatar image.
20
     *
21
     * @see http://en.gravatar.com/site/implement/images/php/
22
     */
23
    public function getGravatarUrl(string $emailAddress = '', array $parameters = []): string
24
    {
25
        $url = 'https://secure.gravatar.com/avatar/';
26
        $url .= md5(mb_strtolower(trim($emailAddress))) . '.jpg';
27
28
        $url .= '?s=' . (isset($parameters['size']) ? (int) $parameters['size'] : 80);
29
        $url .= '&amp;d=' . ($parameters['imageset'] ?? 'mm');
30
        $url .= '&amp;r=' . ($parameters['rating'] ?? 'g');
31
32
        return $url;
33
    }
34
}
35