EventServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 2
b 0
f 0
dl 0
loc 21
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getUnauthorizedOwnerListeners() 0 9 2
A listens() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Created on 10/03/18 by enea dhack.
7
 */
8
9
namespace Enea\Authorization;
10
11
use Enea\Authorization\Events\UnauthorizedOwner;
12
use Enea\Authorization\Listeners\WriteUnauthorizedLog;
13
use Enea\Authorization\Support\Determiner;
14
use Illuminate\Foundation\Support\Providers\EventServiceProvider as BaseEventServiceProvider;
15
16
class EventServiceProvider extends BaseEventServiceProvider
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21 101
    public function listens()
22
    {
23
        return [
24 101
            UnauthorizedOwner::class => $this->getUnauthorizedOwnerListeners(),
25
        ];
26
    }
27
28 101
    private function getUnauthorizedOwnerListeners(): array
29
    {
30 101
        $listeners = array();
31
32 101
        if (Determiner::listenUnauthorizedOwnerEventForLogger()) {
33 101
            $listeners[] = WriteUnauthorizedLog::class;
34
        }
35
36 101
        return $listeners;
37
    }
38
}
39