public function bind($values, $replaceNulls = false)
    {
        if ($values === null) {
            return $this;
        }

        // Check properties type.
        if (!is_array($values) && !is_object($values)) {
            throw new \InvalidArgumentException(sprintf('Please bind array or object, %s given.', gettype($values)));
        }

        // If is Traversable, get iterator.
        if ($values instanceof \Traversable) {
            $values = iterator_to_array($values);
        } elseif (is_object($values)) {
            // If is object, convert it to array
            $values = get_object_vars($values);
        }

        // Bind the properties.
        foreach ($values as $field => $value) {
            // Check if the value is null and should be bound.
            if ($value === null && !$replaceNulls) {
                continue;
            }

            // Set the property.
            $this->offsetSet($field, $value);
        }

        return $this;
    }
public function bind($values, $replaceNulls = false)
    {
        if ($values === null) {
            return $this;
        }

        // Check properties type.
        if (!is_array($values) && !is_object($values)) {
            throw new \InvalidArgumentException(sprintf('Please bind array or object, %s given.', gettype($values)));
        }

        // If is Traversable, get iterator.
        if ($values instanceof \Traversable) {
            $values = iterator_to_array($values);
        } elseif (is_object($values)) {
            // If is object, convert it to array
            $values = get_object_vars($values);
        }

        // Bind the properties.
        foreach ($values as $field => $value) {
            // Check if the value is null and should be bound.
            if ($value === null && !$replaceNulls) {
                continue;
            }

            // Set the property.
            $this->offsetSet($field, $value);
        }

        return $this;
    }
public function bind ( $ values , $ replaceNulls = false ) { if ( $ values === null ) { return $ this ; } // Check properties type. if ( ! is_array ( $ values ) && ! is_object ( $ values ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Please bind array or object, %s given.' , gettype ( $ values ) ) ) ; } // If is Traversable, get iterator. if ( $ values instanceof \ Traversable ) { $ values = iterator_to_array ( $ values ) ; } elseif ( is_object ( $ values ) ) { // If is object, convert it to array $ values = get_object_vars ( $ values ) ; } // Bind the properties. foreach ( $ values as $ field => $ value ) { // Check if the value is null and should be bound. if ( $ value === null && ! $ replaceNulls ) { continue ; } // Set the property. $ this -> offsetSet ( $ field , $ value ) ; } return $ this ; }
Bind the data into this object.

@param   mixed   $values       The data array or object.
@param   boolean $replaceNulls Replace null or not.

@return  static Return self to support chaining.
Bind the data into this object .