Completed
Push — master ( d96527...d84be1 )
by Vladimir
05:46 queued 03:15
created

Consumer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 8 1
A instance() 0 8 2
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
}