Total Complexity | 6 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class DoctrineHelper |
||
8 | { |
||
9 | /** |
||
10 | * Gets the real class name of a class name that could be a proxy. |
||
11 | * |
||
12 | * @param object|string $subject |
||
13 | * |
||
14 | * @return string |
||
15 | * |
||
16 | * credits |
||
17 | * https://github.com/api-platform/core/blob/master/src/Util/ClassInfoTrait.php |
||
18 | */ |
||
19 | /** |
||
20 | * Get the real class name of a class name that could be a proxy. |
||
21 | */ |
||
22 | public static function getRealClassName($class): string |
||
23 | { |
||
24 | $class = \is_object($class) ? \get_class($class) : $class; |
||
25 | |||
26 | // __CG__: Doctrine Common Marker for Proxy (ODM < 2.0 and ORM < 3.0) |
||
27 | // __PM__: Ocramius Proxy Manager (ODM >= 2.0) |
||
28 | if ((false === $positionCg = strrpos($class, '\\__CG__\\')) && |
||
29 | (false === $positionPm = strrpos($class, '\\__PM__\\'))) { |
||
30 | return $class; |
||
31 | } |
||
32 | if (false !== $positionCg) { |
||
33 | return substr($class, $positionCg + 8); |
||
34 | } |
||
35 | $className = ltrim($class, '\\'); |
||
36 | return substr( |
||
37 | $className, |
||
38 | 8 + $positionPm, |
||
|
|||
39 | strrpos($className, '\\') - ($positionPm + 8) |
||
40 | ); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Given a class name and a proxy namespace returns the proxy name. |
||
45 | * |
||
46 | * @param string $className |
||
47 | * @param string $proxyNamespace |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | public static function generateProxyClassName($className, $proxyNamespace): string |
||
54 | } |
||
55 | } |
||
56 |