Test Failed
Push — master ( a4091f...776eb4 )
by Joao
07:11
created

Example   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 17
rs 10
c 0
b 0
f 0
1
<?php
2
3
require "vendor/autoload.php";
4
5
class Example
6
{
7
    use \ByJG\DesignPattern\Singleton;
8
9
    protected $_uniqId;
10
11
    protected function __construct()
12
    {
13
        $this->_uniqId = rand(0, 1000);
14
    }
15
16
    public function getId()
17
    {
18
        return $this->_uniqId;
19
    }
20
21
}
22
23
24
// This works;
25
// Must return the same ID;
26
$example1 = Example::getInstance();
27
echo $example1->getId() . "\n";
28
29
$example2 = Example::getInstance();
30
echo $example2->getId() . "\n";
31
32
33
// That cannot work!
34
$example3 = new Example();
35