Completed
Push — 1.x ( a98302...e42f79 )
by Alexander
07:32
created

IntroductionDemo   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 24
c 1
b 0
f 0
rs 10
1
<?php
2
/*
3
 * Go! AOP framework
4
 *
5
 * @copyright Copyright 2014, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Demo\Example;
12
13
/**
14
 * Example class to show how to dynamically add new interfaces and traits to the class
15
 */
16
class IntroductionDemo
17
{
18
19
    /**
20
     * Method that checks if the current instance implementing Serializable interface
21
     */
22
    public function testSerializable()
23
    {
24
        if ($this instanceof \Serializable) {
25
            echo get_class($this), ' implements `Serializable` interface now!', PHP_EOL;
26
            $reflection = new \ReflectionObject($this);
27
            echo "List of interfaces:", PHP_EOL;
28
            foreach ($reflection->getInterfaceNames() as $interfaceName) {
29
                echo '-> ', $interfaceName, PHP_EOL;
30
            }
31
            echo "List of traits:", PHP_EOL;
32
            foreach ($reflection->getTraitNames() as $traitName) {
33
                echo '-> ', $traitName, PHP_EOL;
34
            }
35
        } else {
36
            echo get_class($this), ' does not implement `Serializable` interface', PHP_EOL;
37
        }
38
    }
39
}
40