PasswordResetBatchElement::apply()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace FSi\Bundle\AdminSecurityBundle\Doctrine\Admin;
13
14
use FSi\Bundle\AdminBundle\Doctrine\Admin\BatchElement;
15
use FSi\Bundle\AdminSecurityBundle\Event\AdminSecurityEvents;
16
use FSi\Bundle\AdminSecurityBundle\Event\ResetPasswordRequestEvent;
17
use FSi\Bundle\AdminSecurityBundle\Security\User\ResettablePasswordInterface;
18
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
19
20
class PasswordResetBatchElement extends BatchElement
21
{
22
    /**
23
     * @var string
24
     */
25
    private $userModel;
26
27
    /**
28
     * @var EventDispatcherInterface
29
     */
30
    private $eventDispatcher;
31
32
    public function __construct(array $options, string $userModel, EventDispatcherInterface $eventDispatcher)
33
    {
34
        parent::__construct($options);
35
36
        $this->userModel = $userModel;
37
        $this->eventDispatcher = $eventDispatcher;
38
    }
39
40
    /**
41
     * @param ResettablePasswordInterface $object
42
     */
43
    public function apply($object): void
44
    {
45
        $this->eventDispatcher->dispatch(
46
            AdminSecurityEvents::RESET_PASSWORD_REQUEST,
0 ignored issues
show
Bug introduced by
FSi\Bundle\AdminSecurity...:RESET_PASSWORD_REQUEST of type string is incompatible with the type object expected by parameter $event of Symfony\Contracts\EventD...erInterface::dispatch(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

46
            /** @scrutinizer ignore-type */ AdminSecurityEvents::RESET_PASSWORD_REQUEST,
Loading history...
47
            new ResetPasswordRequestEvent($object)
0 ignored issues
show
Unused Code introduced by
The call to Symfony\Contracts\EventD...erInterface::dispatch() has too many arguments starting with new FSi\Bundle\AdminSecu...rdRequestEvent($object). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
        $this->eventDispatcher->/** @scrutinizer ignore-call */ 
48
                                dispatch(

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
48
        );
49
    }
50
51
    public function getId(): string
52
    {
53
        return 'admin_security_password_reset';
54
    }
55
56
    public function getClassName(): string
57
    {
58
        return $this->userModel;
59
    }
60
}
61