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

Example::__construct()   A

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
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