Completed
Push — master ( f8a22c...480ba6 )
by ARCANEDEV
12s
created

GenerateConfirmationCode   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 21
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 2
1
<?php namespace Arcanedev\LaravelAuth\Listeners\Users;
2
3
use Arcanedev\LaravelAuth\Events\Users\CreatingUser;
4
use Arcanedev\LaravelAuth\Services\UserConfirmator;
5
6
/**
7
 * Class     GenerateConfirmationCode
8
 *
9
 * @package  Arcanedev\LaravelAuth\Listeners\Users
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class GenerateConfirmationCode
13
{
14
    /* -----------------------------------------------------------------
15
     |  Main Methods
16
     | -----------------------------------------------------------------
17
     */
18
19
    /**
20
     * Handle the event.
21
     *
22
     * @param  \Arcanedev\LaravelAuth\Events\Users\CreatingUser  $event
23
     */
24 36
    public function handle(CreatingUser $event)
25
    {
26 36
        if (UserConfirmator::isEnabled()) {
27 36
            $event->user->confirmation_code = UserConfirmator::generateCode();
0 ignored issues
show
Bug introduced by
Accessing confirmation_code on the interface Arcanesoft\Contracts\Auth\Models\User suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
28 12
        }
29
30 36
        return $event;
31
    }
32
}
33