Set Struct Data From Array

@param array|\Traversable|object|null $data

@throws \InvalidArgumentException
@return $this
509776
final function import($data)
    {
        if ($data === null)
            return $this;

        if (!(is_array($data) || $data instanceof \Traversable || $data instanceof \stdClass))
            throw new \InvalidArgumentException(sprintf(
                'Data must be instance of \Traversable, \stdClass or array. given: (%s) on (%s).'
                , \Poirot\Std\flatten($data), get_class($this)
            ));

        if ($data instanceof \stdClass)
            $data = \Poirot\Std\toArrayObject($data);

        $this->doSetFrom($data);

        return $this;
    }
555268
public function setData(array $data)
    {
        if (isset($data['attachables'])) {
            $this->setAttachables($data['attachables']);
        }

        if (isset($data['groups'])) {
            $this->setGroups($data['groups']);
        }

        if (isset($data['widgets'])) {
            $this->setWidgets($data['widgets']);
        }

        unset($data['attachables'], $data['groups'], $data['widgets']);

        return parent::setData($data);
    }
955543
public function setData(array $data)
    {
        parent::setData($data);

        if (isset($data['page'])) {
            $this->setPage($data['page']);
        }

        if (isset($data['per_page'])) {
            $this->setNumPerPage($data['per_page']);
        }

        if (isset($data['num_per_page'])) {
            $this->setNumPerPage($data['num_per_page']);
        }

        return $this;
    }
791450
public function set(array $data)
	{
		foreach ($data as $key => $value)
		{
			if (isset(static::$_mass_whitelist))
			{
				in_array($key, static::$_mass_whitelist) and $this->_data[$key] = $value;
			}
			elseif (isset(static::$_mass_blacklist))
			{
				( ! in_array($key, static::$_mass_blacklist)) and $this->_data[$key] = $value;
			}
			else
			{
				// no static::$_mass_whitelist or static::$_mass_blacklist set, proceed with default behavior
				$this->_data[$key] = $value;
			}
		}
		return $this;
	}
694610
public function setData($data) 
	{
		if(is_array($data)) {
			$this->data = $data;
		}
		
		$args = func_get_args();
		$this->data[$args[0]] = $args[1];
		
		return $this;
	}
246773
protected function setRequestData(array $data = [])
    {
        if (($this->post instanceof Collection) && (!$this->post->isEmpty())) {
            unset($this->post);
        }

        $this->post = new Collection($data);

        return $this->post;
    }
791200
public function setValues(array $data)
    {
        foreach($data as $key => $value) {
           $this->set($key, $value);
        }

        return $this;
    }
652650
final public function setData($data) {
        if ((is_object($data) && !is_a($data, 'Object')) || (!is_object($data) && !is_array($data)))
            throw new \Exception('Data must be either an array or an object that extends Object: ' . gettype($data));
        $data = is_array($data) ? $data : $data->toArray();
        foreach ($data as $attr => $value) {
            if ($this->elements[$attr]) {
                $this->elements[$attr]->setData($value);
            } else
                $this->data[$attr] = $value;
        }
        $this->valid = null;
        return $this;
    }
1226576
public function setDataFromArray(array $data)
    {
        foreach ($data as $property => $value) {
            $method = 'set' . ucfirst($property);
            if (method_exists($this, $method)) {
                $this->{$method}($value);
            } else {
                throw new \Parable\Routing\Exception(
                    "Tried to set non-existing property '{$property}' with value '{$value}' on " . get_class($this)
                );
            }
        }

        $this->checkValidProperties();
        $this->parseUrlParameters();

        return $this;
    }
1111440
public function setData($Data)
    {
        if (! is_object($Data) || ! $Data instanceof Data) {
            throw new \InvalidArgumentException(
                'The Data Interface must be a valid Data Object'
            );
        }
        $this->Data = $Data;

        return true;
    }
143069
public function addData($data) {
        if (\is_string($data)) {
            $this->addDataSql($data);
        } elseif (\is_array($data)) {
            $this->addDataArray($data);
        } elseif (\is_object($data)) {
            $this->addDataObjectCollection($data);
        } elseif (\is_resource($data)) {
            $this->addDataQueryResource($data);
        } else {
            throw new InvalidArgumentException('Unsupported data type.');
        }
        return $this;
    }
264178
public function setData($data)
    {
        $this->data = [];
        $data       = self::normalizeArray($data);

        foreach ($data as $offset => $value) $this->offsetSet($offset, $value);

        return $this;
    }
714477
public function setData($data = [])
    {
        $this->data = $data;
        $this->debug->info(__FUNCTION__, 'setData: ', $this->data);

        return $this;
    }
764235
public function setData($data)
    {
        $this->data = $data instanceof Structure ? $data : new Structure($data);

        return $this;
    }
564366
public function setData($data)
    {
        if ($this->getEntryType() === FileType::class) {
            $data = self::normalizeFilesArray($data);
        }

        $this->data = $data;

        return $this;
    }
41646
public function fill($data): self {
        if (!is_array($data) && !is_object($data) && $data instanceof \Traversable) {
            throw new \InvalidArgumentException("fill data error");
        }

        // 兼容struct与collection
        foreach ($this instanceof coreInterfaces\Struct ? static::defaults() : $data
            as $key => $value) {

            if (isset($this->_excludeKeys[$key])) {
                continue;
            }
            isset($data[$key]) && $this->set($key, $data[$key]);
        }
        return $this;
    }
1216289
public function fromArray($data)
    {
        if (empty($data)) {
            return $this;
        }
        if (isset($data['type']) && $data['type']) {
            $this->setType($data['type']);
        }
        if (isset($data[$this->getType()]) && $data[$this->getType()]) {
            $this->setValue($data[$this->getType()]);
        }
        return $this;
    }