Passed
Push — master ( e1d378...f1a11e )
by Vitaliy
11:08 queued 21s
created

BeforeDenormalizationEvent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 78
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 78
loc 78
ccs 6
cts 14
cp 0.4286
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A geData() 4 4 1
A getType() 4 4 1
A getFormat() 4 4 1
A getContext() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types = 1);
4
5
/*
6
 * This file is part of the FiveLab Resource package
7
 *
8
 * (c) FiveLab
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code
12
 */
13
14
namespace FiveLab\Component\Resource\Serializer\Events;
15
16
use Symfony\Component\EventDispatcher\Event;
17
18
/**
19
 * Before denormalization event.
20
 *
21
 * @author Vitaliy Zhuk <[email protected]>
22
 */
23 View Code Duplication
class BeforeDenormalizationEvent extends Event
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...
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
{
25
    /**
26
     * @var mixed
27
     */
28
    private $data;
29
30
    /**
31
     * @var string
32
     */
33
    private $type;
34
35
    /**
36
     * @var string
37
     */
38
    private $format;
39
40
    /**
41
     * @var array
42
     */
43
    private $context;
44
45
    /**
46
     * Constructor.
47
     *
48
     * @param mixed  $data
49
     * @param string $type
50
     * @param string $format
51
     * @param array  $context
52
     */
53 4
    public function __construct($data, string $type, string $format, array $context)
54
    {
55 4
        $this->data = $data;
56 4
        $this->type = $type;
57 4
        $this->format = $format;
58 4
        $this->context = $context;
59 4
    }
60
61
    /**
62
     * Get data
63
     *
64
     * @return mixed
65
     */
66
    public function geData()
67
    {
68
        return $this->data;
69
    }
70
71
    /**
72
     * Get type
73
     *
74
     * @return string
75
     */
76
    public function getType(): string
77
    {
78
        return $this->type;
79
    }
80
81
    /**
82
     * Get format
83
     *
84
     * @return string
85
     */
86
    public function getFormat(): string
87
    {
88
        return $this->format;
89
    }
90
91
    /**
92
     * Get context
93
     *
94
     * @return array
95
     */
96
    public function getContext(): array
97
    {
98
        return $this->context;
99
    }
100
}
101