/searchPattern/replace/ * @throws \ByJG\Serializer\Exception\InvalidArgumentException */ public static function bind($source, $target, $propertyPattern = null) { $binderObject = new BinderObject(); $binderObject->bindObjectInternal($source, $target, $propertyPattern); } /** * Bind the properties from a source object to the properties matching to a target object * * @param mixed $source * @param mixed $target * @param string $propertyPattern Regular Expression -> /searchPattern/replace/ * @throws \ByJG\Serializer\Exception\InvalidArgumentException */ protected function bindObjectInternal($source, $target, $propertyPattern = null) { if (is_array($target) || !is_object($target)) { throw new InvalidArgumentException('Target object must have to be an object instance'); } $sourceArray = SerializerObject::instance($source) ->withStopAtFirstLevel() ->serialize(); foreach ($sourceArray as $propName => $value) { if (!is_null($propertyPattern)) { $propAr = explode($propertyPattern[0], $propertyPattern); $propName = preg_replace( $propertyPattern[0] . $propAr[1] . $propertyPattern[0], $propAr[2], $propName ); } $this->setPropValue($target, $propName, $value); } } /** * Set the property value * * @param mixed $obj * @param string $propName * @param string $value */ protected function setPropValue($obj, $propName, $value) { if (method_exists($obj, 'set' . $propName)) { $obj->{'set' . $propName}($value); } elseif (isset($obj->{$propName}) || $obj instanceof stdClass) { $obj->{$propName} = $value; } else { // Check if source property have property case name different from target $className = get_class($obj); if (!isset($this->propNameLower[$className])) { $this->propNameLower[$className] = []; $classVars = get_class_vars($className); foreach ($classVars as $varKey => $varValue) { $this->propNameLower[$className][strtolower($varKey)] = $varKey; } } $propLower = strtolower($propName); if (isset($this->propNameLower[$className][$propLower])) { $obj->{$this->propNameLower[$className][$propLower]} = $value; } } } } __halt_compiler();----SIGNATURE:----k5X7jLB+NtINd3Y79tczU77go9OpSdS0FPiEVco91X90gCkhycKg2uBEiQ4bybcccVUtS42IzhO3vqa6szofItNTAFFH91S5tXYe0OPwgD6c0gzj7yLdqgLmlfmZoJT74onb92Lwy8F1EWkWVYT8M+05BDsZQyTnuzclANBFQ61w5kKwrXf+4PaUPySWpM3/mIoFKCcX3Twrrn16zVXAxFXr7QrE6zO0p2ouU4T5r8MpHX5tzXiLISkooTV8F1iPEJaTVMydYz6nU5GfVzxD6/+jYb9HmI0KpKW/KlOuvACqpYU7rAKJr351AiUJsmCUjv9cG1q9AtKBSH8gerRwyMD/I2ljxkvXtpU+58jS+4LGY2vaFBOlhhIzmN5GzKarQHhn1dG2CFIm/eV49m3irb0xywrKcmTqBIXzTxfALfQOFYFZSVbappN7zNC6Owa9nansK/72WUvVHwjvndDgndGNx/hR6Bx/f9uqnjZ+wZuz34O/NkAxTABpWltI2PtBbVxLTT4LIBNlVUufAgnrbCbZBVOryFqy6btz5qUx5rzAwMkeW3N1hDQ2Rn/mtJi+h+VD1XoIi2eiIkukyul2i1omxZSC4gtUNrBCRVVrNG/nHUhR2jK9rbli3p/vPwLcVO1MlbJg1srnAX3cQJAu9LB1ewgIf7bgOfMqOfP6dMs=----ATTACHMENT:----OTE5NTMyOTk2NzQzNzU3MyA0MDkyNTIwMTQ0MDg0MTcwIDI1NDc4NjU4NzUxNjU0Ng==