SingletonTrait::__wakeup()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
namespace Fwolf\Base\Singleton;
3
4
/**
5
 * Singleton pattern implement
6
 *
7
 * Use only when class REALLY NEED to be singleton, that is say, if class has
8
 * more than one instances, may cause error or waste mass resource. Because
9
 * singleton may introduce tight coupling and hard to mock.
10
 *
11
 * @see         http://www.phptherightway.com/pages/Design-Patterns.html
12
 *
13
 * Illegal usage will cause fatal error and cannot catch, so skip test.
14
 * @codeCoverageIgnore
15
 *
16
 * @copyright   Copyright 2013-2016 Fwolf
17
 * @license     http://opensource.org/licenses/MIT MIT
18
 */
19
trait SingletonTrait
20
{
21
    use SingleInstanceTrait;
22
23
24
    /**
25
     * Prevent 'new' operator from outside
26
     */
27
    protected function __construct()
28
    {
29
    }
30
31
32
    /**
33
     * Prevent clone method
34
     */
35
    private function __clone()
36
    {
37
    }
38
39
40
    /**
41
     * Prevent unserialize method
42
     */
43
    /** @noinspection PhpUnusedPrivateMethodInspection */
44
    private function __wakeup()
45
    {
46
    }
47
}
48