GetGravatarImages::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of the HRis Software package.
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * Licensed under the 3-clause BSD License.
9
 *
10
 * This source file is subject to the 3-clause BSD License that is
11
 * bundled with this package in the LICENSE file.
12
 *
13
 * @version    alpha
14
 *
15
 * @author     Bertrand Kintanar <[email protected]>
16
 * @license    BSD License (3-clause)
17
 * @copyright  (c) 2014-2016, b8 Studios, Ltd
18
 *
19
 * @link       http://github.com/HB-Co/HRis
20
 */
21
22
namespace HRis\Jobs;
23
24
use Illuminate\Contracts\Queue\ShouldQueue;
25
use Illuminate\Queue\InteractsWithQueue;
26
use Illuminate\Queue\SerializesModels;
27
use Illuminate\Support\Facades\Log;
28
use Irradiate\Eloquent\Employee;
29
use Thomaswelton\LaravelGravatar\Facades\Gravatar;
30
31
class GetGravatarImages extends Job implements ShouldQueue
32
{
33
    use InteractsWithQueue, SerializesModels;
34
35
    /**
36
     * @var Employee
37
     */
38
    protected $employee;
39
40
    /**
41
     * Create a new job instance.
42
     *
43
     * @param Employee $employee
44
     */
45
    public function __construct(Employee $employee)
46
    {
47
        $this->employee = $employee;
48
    }
49
50
    /**
51
     * Execute the job.
52
     *
53
     * @return void
54
     */
55
    public function handle()
56
    {
57
        $this->employee->avatar = Gravatar::exists($this->employee->work_email) ? Gravatar::src($this->employee->work_email, 400) : '/images/profile/default/0.png';
58
59
        $this->employee->save();
60
61
        $message = 'Successfully updated avatar of employee_id '.$this->employee->id;
62
63
        Log::info($message);
64
    }
65
}
66