Names   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 11 2
1
<?php
2
3
/**
4
 * Spiral Framework. Cycle ProxyFactory
5
 *
6
 * @license MIT
7
 * @author  Valentin V (Vvval)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Cycle\ORM\Promise;
13
14
use ReflectionClass;
15
16
final class Names
17
{
18
    /**
19
     * @param ReflectionClass $reflection
20
     * @param string|null     $namespace
21
     * @return string
22
     */
23
    public function make(ReflectionClass $reflection, ?string $namespace = null): string
24
    {
25
        $hash = hash('sha256', $reflection->name . $reflection->getFileName());
26
27
        $name = "{$reflection->getShortName()}Proxy_$hash";
28
        if ($namespace !== null) {
29
            return "$namespace\\$name";
30
        }
31
32
        return $name;
33
    }
34
}
35