Passed
Push — master ( 81835c...bfb296 )
by Thorsten
03:09
created

StreamId   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 31
loc 31
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A fromNative() 4 4 1
A toNative() 4 4 1
A equals() 4 4 1
A __toString() 4 4 1
A __construct() 5 5 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
 * This file is part of the daikon-cqrs/cqrs project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
declare(strict_types=1);
10
11
namespace Daikon\EventSourcing\EventStore\Stream;
12
13
use Assert\Assertion;
14
15 View Code Duplication
final class StreamId implements StreamIdInterface
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...
16
{
17
    /** @var string */
18
    private $id;
19
20
    public static function fromNative(string $id): StreamIdInterface
21
    {
22
        return new self(trim($id));
23
    }
24
25
    public function toNative(): string
26
    {
27
        return $this->id;
28
    }
29
30
    public function equals(StreamIdInterface $streamId): bool
31
    {
32
        return $this->id === $streamId->toNative();
33
    }
34
35
    public function __toString(): string
36
    {
37
        return $this->id;
38
    }
39
40
    private function __construct(string $id)
41
    {
42
        Assertion::notEmpty($id);
43
        $this->id = $id;
44
    }
45
}
46