Consumer::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AcquiroPay;
6
7
use RuntimeException;
8
9
final class Consumer
10
{
11
    private $id;
12
13
    private static $instance;
14
15
    public function __construct(int $id)
16
    {
17
        $this->id = $id;
18
    }
19
20
    public static function create(int $id): self
21
    {
22
        $instance = new self($id);
23
24
        self::$instance = $instance;
25
26
        return $instance;
27
    }
28
29
    public static function instance(): self
30
    {
31
        if (self::$instance === null) {
32
            throw new RuntimeException('No instance.');
33
        }
34
35
        return self::$instance;
36
    }
37
38
    public function getId(): int
39
    {
40
        return $this->id;
41
    }
42
}
43