Key * * @var array */ private $map = []; /** * Key => Property * * @var array */ private $reflectedMap = []; /** * @var array */ private $constructors = []; /** * @var array */ private $serializers = []; /** * Rule constructor. * * @param string $class */ public function __construct($class) { $this->class = $class; } /** * Create new rule * * @param string $class * * @return Rule */ public static function create(string $class): Rule { return new Rule($class); } /** * Create rule with one-to-one mapping * * @param string $class * * @return Rule */ public static function createDefault(string $class): Rule { $rule = new Rule($class); $reflection = new \ReflectionClass($class); $properties = $reflection->getProperties(); foreach ($properties as $property) { /** @var \ReflectionProperty $property */ $rule->assign($property->getName(), $property->getName()); } return $rule; } /** * Simple property-key pair assigning * * @param string $property Object property * @param string $key Map key * * @return $this */ public function assign(string $property, string $key) { $this->doAssign($property, $key); return $this; } /** * Assign property constructor * * @param string $property * @param string $key * @param callable $fx * * @return $this */ public function assignConstructor(string $property, string $key, callable $fx) { $this->doAssign($property, $key); $this->constructors[$property] = $fx; return $this; } /** * Assign property serializer * * @param string $property * @param string $key * @param callable $fx * * @return $this */ public function assignSerializer(string $property, string $key, callable $fx) { $this->doAssign($property, $key); $this->serializers[$property] = $fx; return $this; } /** * @return string */ public function getClass(): string { return $this->class; } /** * @return array */ public function getMap(): array { return $this->map; } /** * @return array */ public function getReflectedMap(): array { return $this->reflectedMap; } /** * @param string $property * * @return callable|null */ public function getConstructor(string $property) { return $this->constructors[$property] ?? null; } /** * @param string $property * * @return callable|null */ public function getSerializer(string $property) { return $this->serializers[$property] ?? null; } /** * @param string $property * @param string $key */ private function doAssign(string $property, string $key) { $this->map[$property] = $key; $this->reflectedMap[$key] = $property; } } __halt_compiler();----SIGNATURE:----nLAGJw8ypytVnvuzrsKXa2QytVhPx16m6b/BxkZz0UYr0t9B77Q/tOmENC73jsQ9R7UCfMmrE+3F77DL2ukp+6fkDPnmX1+LIrc+OTlGiNu3y/PRVDASoAvrgOLunZAsIBeB9DStr61X5kgHnGalbTe4f+znBcYvoyqCnvqQ3oHVtu/VNkXbFg6+eAk99L41XqNmgG9FO3y8UijD0QzV4haIDd1+01rXK005Nimbbvrmo2MYHFt7NuM3aKjqVMPGG7VSW/VQ5k991izbKQr8E3cZkN0W/1ZfVX6r3c2FmT4KW01pmumyutILtkfO6CPF9L1fwRsAGcWvMCbLelqvNmDERqf/ls9rm8KzCHpTqbb2OaYyFE+gZ65FzcyVzXGTuJBOCXFQaevAgD6ZYEnHunGG0535cnSILAm3qclLkrSGhtNNQy4ux/PW01BZ9Xc5wd/KZj0gOMRSKsbvZaL5Fiw+LWLw4zQKwXYMXjUBx260gR86JC3bN+vnLoG4OKQjRT8Q1OpqIUMZ7oAVbnHX6F7rBdCfXFwUAtc1Kh4GAJSZ8P1PvJvAvawvptm411OFMItkJ0kiFHHf/v+Yf29fNq3BM2paZji41Q4ZAULbN2dFoFvN0Dd6RYFtPNAhwG0g9HwfzUX2SMh4XmFu6amHL8JbOfW5eLFTjf6uXhhzKLM=----ATTACHMENT:----NDQxNjAxMTYxNDE1OTI4OSAxMDUxNjgxNzAwOTA0MzM5IDE5MzAwMjE4NTI0NTE5ODc=