public function assignArrayToObject(array $array, $object, array $aliases)
    {
        foreach ($array as $name => $value) {
            if (!isset($aliases[$name])) {
                continue;
            }

            if (isset($aliases[$name]['type'])) {
                switch ($aliases[$name]['type']) {
                    case 'date':
                        if (is_null($value) || (is_object($value) && $value instanceof \DateTimeInterface)) {
                            continue;
                        }
                        if (is_numeric($value) && (int)$value == $value) {
                            $time = $value;
                            $value = new \DateTime();
                            $value->setTimestamp($time);
                        } else {
                            $value = new \DateTime($value);
                        }
                        break;
                    case ObjectType::NAME:
                    case Nested::NAME:
                        if ($aliases[$name]['multiple']) {
                            $value = new ObjectIterator($this, $value, $aliases[$name]);
                        } else {
                            if (!isset($value)) {
                                break;
                            }
                            $value = $this->assignArrayToObject(
                                $value,
                                new $aliases[$name]['namespace'](),
                                $aliases[$name]['aliases']
                            );
                        }
                        break;
                    case 'boolean':
                        if (!is_bool($value)) {
                            $value = (bool)$value;
                        }
                        break;
                    default:
                        // Do nothing here. Default cas is required by our code style standard.
                        break;
                }
            }

            if ($aliases[$name]['propertyType'] == 'private') {
                $object->{$aliases[$name]['methods']['setter']}($value);
            } else {
                $object->{$aliases[$name]['propertyName']} = $value;
            }
        }

        return $object;
    }
public function assignArrayToObject(array $array, $object, array $aliases)
    {
        foreach ($array as $name => $value) {
            if (!isset($aliases[$name])) {
                continue;
            }

            if (isset($aliases[$name]['type'])) {
                switch ($aliases[$name]['type']) {
                    case 'date':
                        if (is_null($value) || (is_object($value) && $value instanceof \DateTimeInterface)) {
                            continue;
                        }
                        if (is_numeric($value) && (int)$value == $value) {
                            $time = $value;
                            $value = new \DateTime();
                            $value->setTimestamp($time);
                        } else {
                            $value = new \DateTime($value);
                        }
                        break;
                    case ObjectType::NAME:
                    case Nested::NAME:
                        if ($aliases[$name]['multiple']) {
                            $value = new ObjectIterator($this, $value, $aliases[$name]);
                        } else {
                            if (!isset($value)) {
                                break;
                            }
                            $value = $this->assignArrayToObject(
                                $value,
                                new $aliases[$name]['namespace'](),
                                $aliases[$name]['aliases']
                            );
                        }
                        break;
                    case 'boolean':
                        if (!is_bool($value)) {
                            $value = (bool)$value;
                        }
                        break;
                    default:
                        // Do nothing here. Default cas is required by our code style standard.
                        break;
                }
            }

            if ($aliases[$name]['propertyType'] == 'private') {
                $object->{$aliases[$name]['methods']['setter']}($value);
            } else {
                $object->{$aliases[$name]['propertyName']} = $value;
            }
        }

        return $object;
    }
public function assignArrayToObject ( array $ array , $ object , array $ aliases ) { foreach ( $ array as $ name => $ value ) { if ( ! isset ( $ aliases [ $ name ] ) ) { continue ; } if ( isset ( $ aliases [ $ name ] [ 'type' ] ) ) { switch ( $ aliases [ $ name ] [ 'type' ] ) { case 'date' : if ( is_null ( $ value ) || ( is_object ( $ value ) && $ value instanceof \ DateTimeInterface ) ) { continue ; } if ( is_numeric ( $ value ) && ( int ) $ value == $ value ) { $ time = $ value ; $ value = new \ DateTime ( ) ; $ value -> setTimestamp ( $ time ) ; } else { $ value = new \ DateTime ( $ value ) ; } break ; case ObjectType :: NAME : case Nested :: NAME : if ( $ aliases [ $ name ] [ 'multiple' ] ) { $ value = new ObjectIterator ( $ this , $ value , $ aliases [ $ name ] ) ; } else { if ( ! isset ( $ value ) ) { break ; } $ value = $ this -> assignArrayToObject ( $ value , new $ aliases [ $ name ] [ 'namespace' ] ( ) , $ aliases [ $ name ] [ 'aliases' ] ) ; } break ; case 'boolean' : if ( ! is_bool ( $ value ) ) { $ value = ( bool ) $ value ; } break ; default : // Do nothing here. Default cas is required by our code style standard. break ; } } if ( $ aliases [ $ name ] [ 'propertyType' ] == 'private' ) { $ object -> { $ aliases [ $ name ] [ 'methods' ] [ 'setter' ] } ( $ value ) ; } else { $ object -> { $ aliases [ $ name ] [ 'propertyName' ] } = $ value ; } } return $ object ; }
Assigns all properties to object.

@param array  $array
@param object $object
@param array  $aliases

@return object
Assigns all properties to object .