Completed
Pull Request — master (#2743)
by Jeroen
16:52 queued 10:35
created

BcEvent

Complexity

Total Complexity 0

Size/Duplication

Total Lines 3
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 0
lcom 0
cbo 1
dl 0
loc 3
ccs 0
cts 0
cp 0
c 0
b 0
f 0
1
<?php
2
3
namespace Kunstmaan\VotingBundle\Event;
4
5
use Symfony\Component\EventDispatcher\Event as LegacyEvent;
6
use Symfony\Contracts\EventDispatcher\Event;
7
use Symfony\Component\HttpFoundation\Request;
8
9
if (!class_exists(Event::class)) {
10
    /**
11
     * Symfony 3.4
12
     *
13
     * @internal
14
     */
15
    abstract class BcEvent extends LegacyEvent
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Component\EventDispatcher\Event has been deprecated with message: since Symfony 4.3, use "Symfony\Contracts\EventDispatcher\Event" instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
16
    {
17
    }
18
} else {
19
    /**
20
     * Symfony >= 4.3
21
     *
22
     * @internal
23
     */
24
    abstract class BcEvent extends Event
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type Kunstmaan\VotingBundle\Event\BcEvent has been defined more than once; this definition is ignored, only the first definition in this file (L15-17) is considered.

This check looks for classes that have been defined more than once in the same file.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
25
    {
26
    }
27
}
28
29
abstract class AbstractVoteEvent extends BcEvent implements EventInterface
30
{
31
    /**
32
     * @var Request
33
     */
34
    protected $request;
35
36
    /**
37
     * @var string
38
     */
39
    protected $reference;
40
41
    /**
42
     * @var int
43
     */
44
    protected $value;
45
46
    /**
47
     * @param Request $request
48
     * @param string  $reference
49
     * @param int     $value
50
     */
51 8
    public function __construct(Request $request, $reference, $value)
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
52
    {
53 8
        $this->request = $request;
54 8
        $this->reference = $reference;
55 8
        $this->value = $value;
56 8
    }
57
58
    /**
59
     * @return Request
60
     */
61 8
    public function getRequest()
62
    {
63 8
        return $this->request;
64
    }
65
66
    /**
67
     * @return string
68
     */
69 8
    public function getReference()
70
    {
71 8
        return $this->reference;
72
    }
73
74
    /**
75
     * @return int
76
     */
77 5
    public function getValue()
78
    {
79 5
        return $this->value;
80
    }
81
}
82