CompletedSample   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 57
loc 57
c 0
b 0
f 0
wmc 6
lcom 0
cbo 1
ccs 0
cts 23
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 2
A getName() 4 4 1
A getStartedAt() 4 4 1
A getFinishedAt() 4 4 1
A getData() 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
 * Created by IntelliJ IDEA.
4
 * User: gerk
5
 * Date: 26.01.17
6
 * Time: 12:25
7
 */
8
9
namespace PeekAndPoke\Component\Slumber\FrameworkIntegration\StorageProfiler;
10
11
/**
12
 * @author Karsten J. Gerber <[email protected]>
13
 */
14 View Code Duplication
class CompletedSample
0 ignored issues
show
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...
15
{
16
    /** @var string */
17
    private $name;
18
    /** @var float */
19
    private $startedAt;
20
    /** @var float */
21
    private $finishedAt;
22
    /** @var array */
23
    private $data;
24
25
    /**
26
     * CompletedSample constructor.
27
     *
28
     * @param RunningSample $sample
29
     * @param float|null    $finishedAt
30
     */
31
    public function __construct(RunningSample $sample, $finishedAt = null)
32
    {
33
        $this->name       = $sample->getName();
34
        $this->startedAt  = $sample->getStartedAt();
35
        $this->finishedAt = $finishedAt ?: microtime(true);
36
        $this->data       = $sample->getData();
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function getName()
43
    {
44
        return $this->name;
45
    }
46
47
    /**
48
     * @return float
49
     */
50
    public function getStartedAt()
51
    {
52
        return $this->startedAt;
53
    }
54
55
    /**
56
     * @return float
57
     */
58
    public function getFinishedAt()
59
    {
60
        return $this->finishedAt;
61
    }
62
63
    /**
64
     * @return array
65
     */
66
    public function getData()
67
    {
68
        return $this->data;
69
    }
70
}
71