public function fill($data)
    {
        if (!$this->object) {
            throw new InvalidArgumentException(
                'There are no object to be mapped'
            );
        }

        if (!is_object($data)) {
            throw new InvalidArgumentException('Data should be an object');
        }

        $data = $this->extractData($data);
        $allowed = $this->extractAllowedAttributes($this->class);

        foreach ($this->class->getProperties() as $property) {
            $name = $property->getName();
            if (!in_array($name, $allowed, true)
                || !array_key_exists(
                    $name,
                    $data
                )
            ) {
                continue;
            }

            $property->setAccessible(true);
            $property->setValue($this->object, $data[$name]);
        }

        return $this->object;
    }
public function fill($data)
    {
        if (!$this->object) {
            throw new InvalidArgumentException(
                'There are no object to be mapped'
            );
        }

        if (!is_object($data)) {
            throw new InvalidArgumentException('Data should be an object');
        }

        $data = $this->extractData($data);
        $allowed = $this->extractAllowedAttributes($this->class);

        foreach ($this->class->getProperties() as $property) {
            $name = $property->getName();
            if (!in_array($name, $allowed, true)
                || !array_key_exists(
                    $name,
                    $data
                )
            ) {
                continue;
            }

            $property->setAccessible(true);
            $property->setValue($this->object, $data[$name]);
        }

        return $this->object;
    }
public function fill ( $ data ) { if ( ! $ this -> object ) { throw new InvalidArgumentException ( 'There are no object to be mapped' ) ; } if ( ! is_object ( $ data ) ) { throw new InvalidArgumentException ( 'Data should be an object' ) ; } $ data = $ this -> extractData ( $ data ) ; $ allowed = $ this -> extractAllowedAttributes ( $ this -> class ) ; foreach ( $ this -> class -> getProperties ( ) as $ property ) { $ name = $ property -> getName ( ) ; if ( ! in_array ( $ name , $ allowed , true ) || ! array_key_exists ( $ name , $ data ) ) { continue ; } $ property -> setAccessible ( true ) ; $ property -> setValue ( $ this -> object , $ data [ $ name ] ) ; } return $ this -> object ; }
Fill object from object

@param object $data

@return object
Fill object from object