public function bind($src, $replaceNulls = false)
    {
        // If the source value is not an array or object return false.
        if (!is_object($src) && !is_array($src)) {
            throw new \InvalidArgumentException(sprintf('%s::bind(*%s*)', get_class($this), gettype($src)));
        }

        if ($src instanceof \Traversable) {
            $src = iterator_to_array($src);
        }

        // If the source value is an object, get its accessible properties.
        if (is_object($src)) {
            $src = get_object_vars($src);
        }

        $fields = $this->getFields();

        // Event
        $this->triggerEvent(
            'onBefore' . ucfirst(__FUNCTION__),
            [
                'src' => &$src,
                'fields' => $fields,
                'replaceNulls' => &$replaceNulls,
            ]
        );

        // Bind the source value, excluding the ignored fields.
        foreach ($src as $k => $v) {
            if ($v === null && !$replaceNulls) {
                continue;
            }

            $this->$k = $v;
        }

        // Event
        $this->triggerEvent('onAfter' . ucfirst(__FUNCTION__));

        return $this;
    }
public function bind($src, $replaceNulls = false)
    {
        // If the source value is not an array or object return false.
        if (!is_object($src) && !is_array($src)) {
            throw new \InvalidArgumentException(sprintf('%s::bind(*%s*)', get_class($this), gettype($src)));
        }

        if ($src instanceof \Traversable) {
            $src = iterator_to_array($src);
        }

        // If the source value is an object, get its accessible properties.
        if (is_object($src)) {
            $src = get_object_vars($src);
        }

        $fields = $this->getFields();

        // Event
        $this->triggerEvent(
            'onBefore' . ucfirst(__FUNCTION__),
            [
                'src' => &$src,
                'fields' => $fields,
                'replaceNulls' => &$replaceNulls,
            ]
        );

        // Bind the source value, excluding the ignored fields.
        foreach ($src as $k => $v) {
            if ($v === null && !$replaceNulls) {
                continue;
            }

            $this->$k = $v;
        }

        // Event
        $this->triggerEvent('onAfter' . ucfirst(__FUNCTION__));

        return $this;
    }
public function bind ( $ src , $ replaceNulls = false ) { // If the source value is not an array or object return false. if ( ! is_object ( $ src ) && ! is_array ( $ src ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s::bind(*%s*)' , get_class ( $ this ) , gettype ( $ src ) ) ) ; } if ( $ src instanceof \ Traversable ) { $ src = iterator_to_array ( $ src ) ; } // If the source value is an object, get its accessible properties. if ( is_object ( $ src ) ) { $ src = get_object_vars ( $ src ) ; } $ fields = $ this -> getFields ( ) ; // Event $ this -> triggerEvent ( 'onBefore' . ucfirst ( __FUNCTION__ ) , [ 'src' => & $ src , 'fields' => $ fields , 'replaceNulls' => & $ replaceNulls , ] ) ; // Bind the source value, excluding the ignored fields. foreach ( $ src as $ k => $ v ) { if ( $ v === null && ! $ replaceNulls ) { continue ; } $ this -> $ k = $ v ; } // Event $ this -> triggerEvent ( 'onAfter' . ucfirst ( __FUNCTION__ ) ) ; return $ this ; }
Method to bind an associative array or object to the AbstractTable instance.  This
method only binds properties that are publicly accessible and optionally
takes an array of properties to ignore when binding.

@param   mixed $src          An associative array or object to bind to the AbstractTable instance.
@param   bool  $replaceNulls Replace NULL value.

@return static Method allows chaining

@throws \Exception
@since   2.0
Method to bind an associative array or object to the AbstractTable instance . This method only binds properties that are publicly accessible and optionally takes an array of properties to ignore when binding .