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

StreamId::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 5
loc 5
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
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