AfterDenormalizationEvent   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 78
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A getData() 4 4 1
A getResource() 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 FiveLab\Component\Resource\Resource\ResourceInterface;
17
use Symfony\Component\EventDispatcher\Event;
18
19
/**
20
 * After denormalization event.
21
 *
22
 * @author Vitaliy Zhuk <[email protected]>
23
 */
24 View Code Duplication
class AfterDenormalizationEvent 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...
25
{
26
    /**
27
     * @var mixed
28
     */
29
    private $data;
30
31
    /**
32
     * @var ResourceInterface
33
     */
34
    private $resource;
35
36
    /**
37
     * @var string
38
     */
39
    private $format;
40
41
    /**
42
     * @var array
43
     */
44
    private $context;
45
46
    /**
47
     * Constructor.
48
     *
49
     * @param mixed             $data
50
     * @param ResourceInterface $resource
51
     * @param string            $format
52
     * @param array             $context
53
     */
54 6
    public function __construct($data, ResourceInterface $resource, string $format, array $context)
55
    {
56 6
        $this->data = $data;
57 6
        $this->resource = $resource;
58 6
        $this->format = $format;
59 6
        $this->context = $context;
60 6
    }
61
62
    /**
63
     * Get data
64
     *
65
     * @return mixed
66
     */
67 1
    public function getData()
68
    {
69 1
        return $this->data;
70
    }
71
72
    /**
73
     * Get denormalized resource
74
     *
75
     * @return ResourceInterface
76
     */
77 3
    public function getResource(): ResourceInterface
78
    {
79 3
        return $this->resource;
80
    }
81
82
    /**
83
     * Get format
84
     *
85
     * @return string
86
     */
87 1
    public function getFormat(): string
88
    {
89 1
        return $this->format;
90
    }
91
92
    /**
93
     * Get context
94
     *
95
     * @return array
96
     */
97 1
    public function getContext(): array
98
    {
99 1
        return $this->context;
100
    }
101
}
102