|
13 | 13 |
|
14 | 14 | namespace Rekalogika\Mapper\Transformer\Proxy\Implementation;
|
15 | 15 |
|
16 |
| -use Rekalogika\Mapper\Transformer\ObjectToObjectMetadata\ObjectToObjectMetadata; |
17 | 16 | use Rekalogika\Mapper\Transformer\Proxy\Exception\ProxyNotSupportedException;
|
18 | 17 | use Rekalogika\Mapper\Transformer\Proxy\ProxyGeneratorInterface;
|
19 | 18 | use Rekalogika\Mapper\Transformer\Proxy\ProxySpecification;
|
|
22 | 21 |
|
23 | 22 | final class ProxyGenerator implements ProxyGeneratorInterface
|
24 | 23 | {
|
25 |
| - public function generateTargetProxy(ObjectToObjectMetadata $metadata): ProxySpecification |
| 24 | + public function generateProxy(string $class): ProxySpecification |
26 | 25 | {
|
27 |
| - $sourceClass = $metadata->getSourceClass(); |
28 |
| - $targetClass = $metadata->getTargetClass(); |
29 |
| - |
30 | 26 | /** @var class-string */
|
31 |
| - $proxyClass = $this->generateProxyClassName($sourceClass, $targetClass); |
| 27 | + $proxyClass = $this->generateProxyClassName($class); |
32 | 28 |
|
33 | 29 | try {
|
34 |
| - $proxyCode = $this->generateProxyCode($sourceClass, $targetClass); |
| 30 | + $proxyCode = $this->generateProxyCode($class); |
35 | 31 | } catch (LogicException $e) {
|
36 |
| - throw new ProxyNotSupportedException($metadata, $e); |
| 32 | + throw new ProxyNotSupportedException($class, $e); |
37 | 33 | }
|
38 | 34 |
|
39 | 35 | return new ProxySpecification($proxyClass, $proxyCode);
|
40 | 36 | }
|
41 | 37 |
|
42 | 38 | /**
|
43 |
| - * @param class-string $sourceClass |
44 |
| - * @param class-string $targetClass |
| 39 | + * @param class-string $class |
45 | 40 | * @return string
|
46 | 41 | */
|
47 |
| - private function generateProxyClassName(string $sourceClass, string $targetClass): string |
| 42 | + private function generateProxyClassName(string $class): string |
48 | 43 | {
|
49 | 44 | return sprintf(
|
50 | 45 | 'Rekalogika\Mapper\Generated\__CG__\%s',
|
51 |
| - $targetClass |
| 46 | + $class |
52 | 47 | );
|
53 | 48 | }
|
54 | 49 |
|
55 | 50 | /**
|
56 |
| - * @param class-string $sourceClass |
57 |
| - * @param class-string $targetClass |
| 51 | + * @param class-string $class |
58 | 52 | * @return string
|
59 | 53 | */
|
60 |
| - private function generateProxyCode(string $sourceClass, string $targetClass): string |
| 54 | + private function generateProxyCode(string $class): string |
61 | 55 | {
|
62 |
| - $proxyClass = $this->generateProxyClassName($sourceClass, $targetClass); |
63 |
| - $targetReflection = new \ReflectionClass($targetClass); |
| 56 | + $proxyClass = $this->generateProxyClassName($class); |
| 57 | + $targetReflection = new \ReflectionClass($class); |
64 | 58 |
|
65 | 59 | // get proxy class name & namespace
|
66 | 60 | $shortName = preg_replace('/.*\\\\/', '', $proxyClass);
|
|
0 commit comments