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:----G0haHWDVN9yACkz4YQM3qTQGSQrCLnXkWePmisMb6qjNf7VEunlhCFmjGTp+1CiqGIK/kte1gCDZP/ZAe+8W9kioczAsw08H3vjVCh5dbU0soDUoSH+bVfEnXAXJEe0Io6SVHXA46oEQ6YNGOEL6/T9zXWuKcfkA4Ro3moUUxrlWQZxz1yIdMnvo3jqois39MUP1g8bNSX+UsfJyQeitlyI/ZRblhaNG6B+JtznO6VjMzzifRAW0j0wCrxvcIEjge2BEIX4bZ+7apwGPpvFnXxC5+gP4FHGCMD/ldtjvietcMe8C02kU90Vdvz2C99MRQLim8ZAesBNyeowb4rcYMH0kzyqzXIRiw9cTVxmNWArSn0jOsc1V7oUJpDnq2GjZS+EwfHtVKawbC9V70mQ4a2q/IeZGOivJ44pvobCigHZ/N/Lu//zHDzFvjroFagPoh47YNew8pyJnHKFEzqc03q93VZlP0oM8xJiTwF0qb9Ll+Sah8RTPzYHdJR86qwy41yU/aCoTT0MFuIeWOLQ5GF8FP6r1mpTR0ayEYBpY7XeWDrpn+1sfLEsuSE70oF/MUf7WuwzRuPfWhUsueStcGg8SccrDPqhZ4AoN9YbBeAoBE74Gxup6mFDhH5pIGBLCpDMNiHgtPupM4Y5XXN/k5mWgofaBDi978C05FRf2b5s=----ATTACHMENT:----MjMyNjE5OTU0NjIwODAyMyA4MjI5ODQyNzE0ODM4NDA2IDcwMTA5OTYyMTA2MTExODQ=