/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:----N53c4N+ezVtClIvyU28Oon5IjbwY0BqoEr5qZr8wIKlSWWHYj7mvRcPSNBiexQci8JLV1HGwpcCQIocNuRZ1WNrJZ+NadDsayY/o+Jc5PBY4SVqfMpY81BApmMSa7RN+uzsr6wrU5BuDkvuc0FSJQAJ+HdahFaXYMU5+pwFHg4K2VxbfIxVW7fmyzuCYy+W14+6N+u6Aet0CMq/CvjXGQjSLxt6kH5m+0EVNMhZamRGlddtqIqD6UW4+7VFR9HdXLlFmziP5NQOMSSEDm7kxvN2iKQLWWyX1KjCHzU3elwivSc/hypjrNbG7gf66jEekei+DKHqeiUielk5pMOv/BAtNaPMyhLwXOIhdqBlyT41PgCEj2S0FFopqjiZInbjnZq51r0htnitrPmOVEalxCsXTJRA1yUR3l8j8ph6jau7lu+UcUT/ZFsl1HgfpqEO6bv36eR0xiO40unz/LyUUDuwLbeUFkgSNJrX56DolbCxQJfT5f0hpli3NhAL75oeUEdfjGfQlY7xexpDS6RvPn2glcHFVN8umpNO2kPpfe08YRFCTUJFz+cvKxqXaYWHTkBLbiweePzx3HJ31iDlaLjYZkt1OWEqmcoj50QAteTmERIfDXWIRjt4O2MKzj0f6fNwIpwJxrXU4ot1aCFQMQmtbKFF+1MJVD+/uSP1aqC4=----ATTACHMENT:----NjcwNzI0MTA2NDU4NDM1OSA3MTY3NzExMjE0Nzk2MTU5IDExOTQ2MDkxNDA0MjY0NjY=