Completed
Push — master ( f2cd13...82e8ab )
by Mihail
03:03
created

ClassTools::createStringClassSnapshotHash()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
namespace Ffcms\Core\Traits;
4
5
/**
6
 * Assistance tools for fast using some magical things and opportunity of classic object-oriented programming
7
 */
8
trait ClassTools
9
{
10
11
    /**
12
     * Create hash string from current class properties and itself values.
13
     * This method is good stuff for caching dynamic instances
14
     * @return string|null
15
     */
16
    public function createStringClassSnapshotHash()
17
    {
18
        $hash = null;
19
        foreach ($this as $property => $value) {
0 ignored issues
show
Bug introduced by
The expression $this of type this<Ffcms\Core\Traits\ClassTools> is not traversable.
Loading history...
20
            $hash = md5($hash . $property . '=' . $value);
21
        }
22
        return $hash;
23
    }
24
}