Id::getBase62Id()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Nastoletni\Code\Domain\Paste;
6
7
use Nastoletni\Code\Application\Base10And62Converter;
8
9
class Id
0 ignored issues
show
Coding Style introduced by
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
10
{
11
    /**
12
     * @var int
13
     */
14
    private $id;
15
16
    /**
17
     * Id constructor.
18
     *
19
     * @param int $id
20
     */
21 8
    private function __construct(int $id)
22
    {
23 8
        $this->id = $id;
24 8
    }
25
26
    /**
27
     * Creates Id from ordinary, 10 base number [0-9].
28
     *
29
     * @param int $id
30
     *
31
     * @return Id
32
     */
33 7
    public static function createFromBase10(int $id): Id
34
    {
35 7
        return new static($id);
36
    }
37
38
    /**
39
     * Creates Id from base 62 number [0-9a-zA-Z].
40
     *
41
     * @param string $id
42
     *
43
     * @return Id
44
     */
45 1
    public static function createFromBase62(string $id): Id
46
    {
47 1
        return new static(Base10And62Converter::base62To10($id));
48
    }
49
50
    /**
51
     * @return int
52
     */
53 4
    public function getBase10Id(): int
54
    {
55 4
        return $this->id;
56
    }
57
58
    /**
59
     * @return string
60
     */
61 2
    public function getBase62Id(): string
62
    {
63 2
        return Base10And62Converter::base10To62($this->id);
64
    }
65
}
66