Completed
Push — master ( 52ee14...16f440 )
by Manuel
11:23 queued 08:50
created

UpdateStatistics   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 28
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 18 1
1
<?php
2
3
namespace PiFinder\Handlers\Events;
4
5
use Carbon\Carbon;
6
use Illuminate\Support\Facades\DB;
7
use PiFinder\DeviceArchive;
8
use PiFinder\Events\ServerWasPoked;
9
use PiFinder\Poke;
10
use PiFinder\Utilities\ExtractNetwork;
11
12
class UpdateStatistics
13
{
14
    /**
15
     * Handle the event.
16
     *
17
     * @param ServerWasPoked $event
18
     *
19
     * @return void
20
     */
21 4
    public function handle(ServerWasPoked $event)
22
    {
23 4
        $device = $event->getDevice()->toArray();
24
25
        // device count
26 4
        DeviceArchive::updateOrCreate(
0 ignored issues
show
Bug introduced by
The method updateOrCreate() does not exist on PiFinder\DeviceArchive. Did you maybe mean create()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
27 4
            ['mac_hash' => md5($device['mac'])],
28 4
            ['updated_at' => Carbon::now()]
29 4
        );
30
31
        // network distribution
32 4
        $network = ExtractNetwork::fromIp($device['ip']);
33 4
        DB::table('network_distribution')->where('network', $network)->increment('pokes');
34
35
        // pokes
36 4
        $date = Carbon::now()->toDateString();
37 4
        Poke::firstOrCreate(['date' => $date])->increment('pokes');
0 ignored issues
show
Bug introduced by
The method firstOrCreate() does not exist on PiFinder\Poke. Did you maybe mean create()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
38 4
    }
39
}
40