Completed
Push — feature/EVO-7278-tracking-info... ( d73a1e )
by
unknown
63:38
created

DBActivityListener   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 56
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A postLoad() 0 4 1
A prePersist() 0 4 1
A preUpdate() 0 4 1
A preRemove() 0 4 1
1
<?php
2
namespace Graviton\AuditTrackingBundle\Listener;
3
4
use Doctrine\ODM\MongoDB\Event\LifecycleEventArgs;
5
use Graviton\AuditTrackingBundle\Manager\ActivityManager;
6
7
/**
8
 * Class DBActivityListener
9
 * @package Graviton\AuditTrackingBundle\Listener
10
 */
11
class DBActivityListener
12
{
13
    /** @var ActivityManager */
14
    private $manager;
15
16
    /**
17
     * DBActivityListener constructor.
18
     * @param ActivityManager $activityManager Business logic
19
     */
20
    public function __construct(ActivityManager $activityManager)
21
    {
22
        $this->manager = $activityManager;
23
    }
24
25
    /**
26
     * After Loading
27
     * @param LifecycleEventArgs $args Mongo.odm event argument
28
     * @return void
29
     */
30
    public function postLoad(LifecycleEventArgs $args)
31
    {
32
        $this->manager->registerDatabaseEvent('postLoad', $args->getDocument());
0 ignored issues
show
Documentation introduced by
$args->getDocument() is of type object, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
33
    }
34
35
    /**
36
     * Before saving
37
     * @param LifecycleEventArgs $args Mongo.odm event argument
38
     * @return void
39
     */
40
    public function prePersist(LifecycleEventArgs $args)
41
    {
42
        $this->manager->registerDatabaseEvent('prePersist', $args->getDocument());
0 ignored issues
show
Documentation introduced by
$args->getDocument() is of type object, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
43
    }
44
45
    /**
46
     * Before update
47
     * @param LifecycleEventArgs $args Mongo.odm event argument
48
     * @return void
49
     */
50
    public function preUpdate(LifecycleEventArgs $args)
51
    {
52
        $this->manager->registerDatabaseEvent('preUpdate', $args->getDocument());
0 ignored issues
show
Documentation introduced by
$args->getDocument() is of type object, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
53
    }
54
55
56
    /**
57
     * Before deleting
58
     * @param LifecycleEventArgs $args Mongo.odm event argument
59
     * @return void
60
     */
61
    public function preRemove(LifecycleEventArgs $args)
62
    {
63
        $this->manager->registerDatabaseEvent('preRemove', $args->getDocument());
0 ignored issues
show
Documentation introduced by
$args->getDocument() is of type object, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
64
    }
65
66
}