@param array|UnitAddTransfer $data
@return int

@throws InvalidArgumentException
@throws ServerException
345446
public function post($data)
	{
		if (!$data instanceof UnitAddTransfer) {
			if (!is_array($data)) {
				throw new InvalidArgumentException('Data argument should be an array of instance of UnitAddTransfer');
			}
			$data = UnitAddTransfer::make($data);
		}

		$endpoint = new Post($this->getTransport());
		$endpoint->setTransfer($data);

		$resultRequest = $endpoint->performRequest();

		return Response::extractId($resultRequest, '/units/%d/');
	}
258094
static public function createFromArray(array $data)
    {
        if (4 != count($data)) {
            throw new InvalidArgumentException("Expected data as a 4 length array.");
        }

        $filter = new static($data[0], $data[1]);
        $filter->setOperator($data[2]);
        $filter->setValue(unserialize($data[3]));

        return $filter;
    }
1306346
public function resolveDataValue($data)
    {
        if ($data instanceof Data) {

            return $this->setData($data);

        } elseif (is_array($data)) {

            return $this->setData(new Data($data));
        }

        throw new \InvalidArgumentException(
            "Data must be View\Data or array value"
        );
    }
121361
private function importData(string $data): int
    {
        $errorCount = 0;

        foreach ($this->importer->importData($data) as $index => $result) {
            if ($result instanceof SuccessResult) {
                $this->io->note(
                    sprintf(
                        'Imported %1$s #%2$d into %1$s ID %3$d',
                        $result->getEntityType(),
                        $index + 1,
                        $result->getEntityId()
                    )
                );

                continue;
            }

            if ($result instanceof ErrorResult) {
                $this->io->error(sprintf('Could not import %s #%d', $result->getEntityType(), $index + 1));
                $this->io->section('Error stack:');
                $this->renderThrowableStack($result->getError());
                $this->io->newLine();

                ++$errorCount;

                continue;
            }
        }

        return $errorCount;
    }
108174
public function row(array $data): int
    {
        array_push($this->rows, $data);
        $pdoStatement = $this->provideStatement();
        $this->execute($pdoStatement);
        return $this->getLastInsertId();
    }
1046281
public function setData($data)
    {
        $this->data = $data;

        if (is_string($this->data)) {
            $this->data = json_decode($this->data, true);
        } else if (is_object($data)) {
            $this->data = json_decode(json_encode($this->data), true);
        } else if (!is_array($data)) {
            throw new \InvalidArgumentException(sprintf('Invalid data type in JsonStore. Expected object, array or string, got %s', gettype($data)));
        }
    }
573376
public function Limit( $data )
	{
		Deprecation::getInstance()->setExceptionVersion( '0.9' )
			->message(  'use setLimit and setOffset instead' );
		if( !is_array( $data ) )
			throw new InvalidArgumentException( 'Limit must be given as List of Offset and Row Limit.' );
		$offset	= 0;
		$rows	= 10;
		if( isset( $data[0] ) && (int) $data[0] && $data[0] == abs( $data[0] ) )
			$offset	= (int) $data[0];
		if( isset( $data[1] ) && (int) $data[1] && $data[1] == abs( $data[1] ) )
			$rows	= (int) $data[1];
		$this->builder->setLimit( $rows );
		$this->builder->setOffset( $offset );
		return array();
	}
1351084
public function setData($data)
    {
        if (!is_array($data)) {
            throw new \InvalidArgumentException(sprintf('Messages custom data must be array, "%s" given.', gettype($data)));
        }

        if (array_key_exists("aps", $data)) {
            unset($data["aps"]);
        }

        foreach ($data as $key => $value) {
            $this->addCustomData($key, $value);
        }

        return $this;
    }
176077
function fromRawData($data)
    {
        $versionVarInt = VarInt::readUnsignedVarInt($data);
        $data = substr($data, $versionVarInt->getDataLength());

        $addressStringLength = VarInt::readUnsignedVarInt($data);
        $data = substr($data, $addressStringLength->getDataLength());

        $address = substr($data, 0, $addressStringLength->getValue());
        $data = substr($data, $addressStringLength->getValue());

        $portShort = unpack('nshort', substr($data, 0, 2))['short'];
        $data = substr($data, 2);

        $nextVarInt = VarInt::readUnsignedVarInt($data);

        try {
            $nextStage = Stage::get($nextVarInt->getValue());

            //disconnect if not a valid stage
            if ($nextStage != Stage::LOGIN() && $nextStage != Stage::STATUS()) {
                throw new InvalidDataException('Stage must be LOGIN or STATUS on handshake');
            }

            //set all of the data
            $this->setNextStage($nextStage)
                ->setServerPort($portShort)
                ->setProtocolVersion($versionVarInt->getValue())
                ->setServerAddress($address);
        } catch (InvalidArgumentException $ex) {
            throw new InvalidDataException('Stage is not a valid number');
        }
    }
626483
public function addData($data) : void
    {
        Assert::isInstanceOfAny($data, [Chunk::class, X509Certificate::class]);
        $this->data[] = $data;
    }
208204
protected static function getFirstRow(array $data)
    {
        if (empty($data)) {
            throw new \InvalidArgumentException('Empty data.');
        }

        list($first) = $data;

        if (!is_array($first)) {
            throw new \InvalidArgumentException('$data is not an array of array.');
        }

        return $first;
    }
974267
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;
    }
659033
public function provide($data = null, array $options = [])
    {
        // Sanitize
        $number = filter_var($data, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);

        if ($number === false) {
            throw new InvalidArgumentException('Failed to sanitize number');
        }
        $decimals = isset($options['precision']) ? $options['precision'] : static::PRECISION;

        return number_format((float)$number, $decimals);
    }
593848
public static function normalizeArray($data)
    {
        if ($data instanceof DataObjectInterface) {
            $data = $data->getData();
        } else if ($data instanceof \ArrayObject) {
            $data = $data->getArrayCopy();
        } else if ($data instanceof \Traversable) {
            $data = iterator_to_array($data);
        }

        if (!is_array($data)) throw new \InvalidArgumentException();

        return $data;
    }
122149
public function update(array $data): int
    {
        $this->builder->setUpdateData($data);
        $sql = $this->builder->buildSql();
        $this->builder = new QueryBuilder($this->pdo);
        return $this->execSql($sql);
    }
370720
public function append($data)
	{
		if($data instanceof AbstractToken)
		{
			$this->tokens[] = $data;
		}
		elseif($data instanceof AbstractTokenContainer)
		{
			$this->tokens = array_merge($this->tokens, $data->toArray());
		}
		elseif($data instanceof AbstractTokenCursor)
		{
			while($data->valid())
			{
				$this->tokens[] = $data->current();
				
				$data->next();
			}
		}
		else
		{
			throw new \InvalidArgumentException('Cannot append data to token buffer: ' . gettype($data));
		}
		
		return $this;
	}
894450
public function setData($data)
    {
        if (!is_array($data) && !is_object($data)) {
            throw new \InvalidArgumentException(sprintf(
                'Expected argument of type array or object, "%s" given',
                is_object($data) ? get_class($data) : gettype($data)
            ));
        }
        $this->data = $data;
        return $this;
    }