Identicon::resolveAttribute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Swatty007\NovaEasyAvatars\Fields;
4
5
use Identicon\Identicon as IdenticonBase;
6
7
class Identicon extends AvatarBase
8
{
9
    /**
10
     * Resolve the given attribute from the given resource.
11
     *
12
     * @param  mixed  $resource
13
     * @param  string  $attribute
14
     * @return mixed
15
     */
16
    protected function resolveAttribute($resource, $attribute)
17
    {
18
        $callback = function () use ($resource, $attribute) {
19
            return (new IdenticonBase())->getImageDataUri($resource->{$attribute}, $this->size);
20
        };
21
22
        $this->preview($callback)->thumbnail($callback);
23
    }
24
}
25