Gravatar   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 1
dl 0
loc 40
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 6 1
A setEmailHash() 0 4 1
A getEmailHash() 0 4 2
A hashEmail() 0 5 2
1
<?php
2
/**
3
 * AdminLte Theme for Yii2 projects
4
 *
5
 * @link      https://github.com/hiqdev/yii2-theme-adminlte
6
 * @package   yii2-theme-adminlte
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\themes\adminlte\widgets;
12
13
class Gravatar extends \cebe\gravatar\Gravatar
14
{
15
    public $defaultImage = 'identicon';
16
17
    public $alt;
18
19
    public $size = 25;
20
21
    public $defaultOptions = [
22
        'class' => 'img-circle',
23
    ];
24
25
    public function init()
26
    {
27
        parent::init();
28
        $this->options['alt'] = $this->alt;
29
        $this->options = array_merge($this->defaultOptions, (array) $this->options);
30
    }
31
32
    protected $_emailHash;
33
34
    public function setEmailHash($hash)
35
    {
36
        $this->_emailHash = $hash;
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function getEmailHash()
43
    {
44
        return $this->_emailHash ?: self::hashEmail($this->email);
45
    }
46
47
    public static function hashEmail($email)
48
    {
49
        $email = strtolower(trim($email));
50
        return strpos($email, '@') === false ? $email : md5($email);
51
    }
52
}
53