Initials::resolveAttribute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

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