Adds data to the object
@param array $data
@param boolean $preserveArray Indicates whether to preserve array or turn them objects too
@return Object
@throws \Exception
769742
public function add(array $data, $preserveArray = false, $preserveKeyOnly = null) {
        foreach ($data as $key => $value) {
            if (is_array($value) && (!$preserveArray || ($preserveArray && $preserveKeyOnly && $key !== $preserveKeyOnly))) {
                $this->$key = (array_key_exists(0, $value)) ? $value : new Object($value, $preserveArray, $preserveKeyOnly);
                continue;
            }

            if (is_int($key)) {
                $this->integerKeys[$key] = $value;
                continue;
            }

            $attr = Util::hyphenToCamel(Util::_toCamel($key));
            $this->{$attr} = $value;
        }
        return $this;
    }
1303963
public function add(array $data)
    {
        $data = $this->resolverFactory->createNewDeviceResolver()->resolve($data);

        return $this->api->request('POST', '/players', [], json_encode($data));
    }
1273476
public function __fromArray(array $data): void
    {
        $hasArrayAccess = $this instanceof \ArrayAccess;
        foreach ($data as $name => $value) {
            $currentValue = null;
            $currentValueIsSet = false;
            $isReadOnly = false;
            if (isset($this->internalDataObjectData['p' . $name])) {
                $propertyData = $this->internalDataObjectData['p' . $name];
                $valueIsSet = false;
                if (isset($propertyData[6])) { // type
                    $type = $propertyData[6];
                    $isNullable = $type[0] === '?';
                    if ($isNullable) {
                        $type = substr($type, 1);
                    }
                } else {
                    $type = null;
                    $isNullable = true;
                }
                if (isset($propertyData[5])) { // readonly
                    $currentValue = $this->$name;
                    $currentValueIsSet = true;
                    $isReadOnly = true;
                } elseif (isset($propertyData[1])) { // init
                    $currentValue = $this->$name;
                    $currentValueIsSet = true;
                } elseif ($type !== null && $type !== 'array' && $type !== 'float' && $type !== 'int' && $type !== 'string') {
                    if ($value !== null) {
                        if (class_exists($type)) {
                            if (is_callable([$type, 'fromArray'])) {
                                if (is_array($value)) {
                                    $value = call_user_func([$type, 'fromArray'], $value);
                                    $valueIsSet = true;
                                } else {
                                    throw new \Exception('Cannot assing value of type ' . gettype($value) . ' to an object!');
                                }
                            } else {
                                $currentValue = new $type();
                                $currentValueIsSet = true;
                            }
                        } else {
                            throw new \Exception('Cannot find class named ' . $type . ' for property ' . $name . '!');
                        }
                    } else {
                        if ($isNullable) {
                            $value = null;
                            $valueIsSet = true;
                        } else {
                            throw new \Exception('The property ' . $name . ' value cannot be null!');
                        }
                    }
                }
                if (!$currentValueIsSet && isset($propertyData[0])) { // default init
                    $currentValue = $this->$name;
                }
                if (!$valueIsSet && is_object($currentValue)) {
                    if (method_exists($currentValue, '__fromArray')) {
                        $currentValue->__fromArray($value);
                    } elseif ($type === 'DateTime') {
                        $currentValue->setTimestamp(strtotime($value));
                    } else {
                        if (is_array($value)) {
                            $_hasArrayAccess = $currentValue instanceof \ArrayAccess;
                            foreach ($value as $_name => $_value) {
                                if ($_hasArrayAccess) {
                                    $currentValue[$_name] = $_value;
                                } else {
                                    $currentValue->$_name = $_value;
                                }
                            }
                        } else {
                            throw new \Exception('Cannot assing value of type ' . gettype($value) . ' to an object!');
                        }
                    }
                    $value = $currentValue;
                }
            }
            if (!$isReadOnly) {
                if ($hasArrayAccess) {
                    $this[$name] = $value;
                } else {
                    $this->$name = $value;
                }
            }
        }
    }
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;
    }
417725
public function saveCategory($data = [])
    {
        if (!empty($data)) {
            $this->data($data);
        }
        $validate = new \gmars\rbac\validate\PermissionCategory();
        if (!$validate->check($this)) {
            throw new Exception($validate->getError());
        }
        $data = $this->getData();
        if (isset($data['id']) && !empty($data['id'])) {
            $this->isUpdate(true);
        }
        $this->save();
        return $this;
    }
1101996
public function insert(array $data) {
        $this->notifyObservers('beforeInsert', array($this, &$data));
        $pkData = parent::insert($data);
        $this->notifyObservers('afterInsert', array($this, $data, $pkData));
        return $pkData;
    }
524755
public function add(array $data)
    {
        if (!$this->isDb()) {
            return false;
        }

        $data += array(
            'created' => GC_TIME,
            'log_id' => gplcart_string_random(6)
        );

        try {
            $result = (bool) $this->db->insert('log', $data);
        } catch (Exception $ex) {
            $result = false;
        }

        return $result;
    }
865927
public function add(array $data): Insert
    {
        if (!isset($data[0]) && count($this->fields) == 0) {
            $this->fields(array_keys($data));
        }

        $this->data[] = $data;
        return $this;
    }
279202
protected function persist(array $data)
    {
        Assertion::notEmpty(
            $this->persistors,
            'No persistor attached.',
            DataAggregatorException::NO_PERSISTOR_ATTACHED
        );

        foreach ($this->persistors as $persistor) {
            try {
                $persistor->persist($data);

            } catch (PersistorException $e) {
                $this->getLogger()->error($e->getMessage());
            }
        }
    }
1026583
private function addEdgesFromArray(array $data)
    {
        $_edgeClass = $this->_edgeClass;

        $this->_result[] = $_edgeClass::createFromArray($data, $this->_options);
    }
694610
public function setData($data) 
	{
		if(is_array($data)) {
			$this->data = $data;
		}
		
		$args = func_get_args();
		$this->data[$args[0]] = $args[1];
		
		return $this;
	}
683161
public function save(array $data = []) : bool
    {
        $this->fill($data);
        $result = null;

        if ($this->exists()) {
            $result = $this->update();
        } else {
            $result = $this->insert();
        }

        return $result->count() > 0;
    }
332035
public static function add($collection, $data)
  {
    static::checkConnexion();
    $collection = self::$db->$collection;
    if (is_string($data)) {
      $data = json_decode($data, true);
      if(!$data){
        throw new \Exception('Requête JSON formulée incorrectement');
      }
    }
    $r = $collection->insert($data);
    if ($r['ok']) {
      return true;
    } else {
      return false;
    }
  }
604725
public function save($data)
    {
        if (is_array($data)) {
            foreach ($data as $entity) {
                $this
                    ->manager
                    ->persist($entity);
            }
        } else {
            $this
                ->manager
                ->persist($data);
        }

        $this
            ->manager
            ->flush($data);

        return $data;
    }
1131829
public function add($data = [])
    {
        $insertId = $this->db->insert($data)->into($this->table)->execute(FALSE);

        return $insertId;
    }
478995
public static function create(array $data = [])
    {
        if (isset($data[0]) && is_array($data[0])) {

            $collection = new Collection();

            foreach ($data as $row) {
                /** @var ORM $obj */
                $class = get_called_class();
                $obj = new $class();
                $obj->setState($row);
                $obj->save();

                $collection->add($obj);
            }

            return $collection;
        }

        /** @var ORM $obj */
        $class = get_called_class();
        $obj = new $class();
        $obj->setState($data);
        $obj->save();

        return $obj;
    }
611929
public function add(array $data)
    {
        $data = $this->resolverFactory->createAppResolver()->resolve($data);

        return $this->api->request('POST', '/apps', [
            'Authorization' => 'Basic '.$this->api->getConfig()->getUserAuthKey(),
        ], json_encode($data));
    }