Applies the actions to the data list provided.

@param mixed $data
@param array $actions
@throws \InvalidArgumentException
@return array Returns the updated data
498295
private function internalDataListUpdateData($data, $actions): array
    {
        if (is_callable($data)) {
            $actionsList = [];
            foreach ($actions as $actionData) {
                if ($actionData[0] === 'filterBy') {
                    $class = $this->internalDataListClasses['IvoPetkov\DataListFilterByAction'];
                    $action = new $class();
                    $action->property = $actionData[1];
                    $action->value = $actionData[2];
                    $action->operator = $actionData[3];
                } elseif ($actionData[0] === 'sortBy') {
                    $class = $this->internalDataListClasses['IvoPetkov\DataListSortByAction'];
                    $action = new $class();
                    $action->property = $actionData[1];
                    $action->order = $actionData[2];
                } elseif ($actionData[0] === 'sliceProperties') {
                    $class = $this->internalDataListClasses['IvoPetkov\DataListSlicePropertiesAction'];
                    $action = new $class();
                    $action->properties = $actionData[1];
                } elseif ($actionData[0] === 'slice') {
                    $class = $this->internalDataListClasses['IvoPetkov\DataListSliceAction'];
                    $action = new $class();
                    $action->offset = $actionData[1];
                    $action->limit = $actionData[2];
                } else {
                    $class = $this->internalDataListClasses['IvoPetkov\DataListAction'];
                    $action = new $class();
                }
                $action->name = $actionData[0];
                $actionsList[] = $action;
            }
            $class = $this->internalDataListClasses['IvoPetkov\DataListContext'];
            $context = new $class();
            $context->actions = $actionsList;
            $dataSource = call_user_func($data, $context);
            if (is_array($dataSource) || $dataSource instanceof \Traversable) {
                $data = [];
                foreach ($dataSource as $value) {
                    $data[] = $value;
                }
            } else {
                throw new \InvalidArgumentException('The data source callback result is not iterable!');
            }
        }
        foreach ($actions as $action) {
            if ($action[0] === 'filter') {
                $this->internalDataListUpdateAllValuesIfNeeded($data);
                $temp = [];
                foreach ($data as $object) {
                    if (call_user_func($action[1], $object) === true) {
                        $temp[] = $object;
                    }
                }
                $data = $temp;
                unset($temp);
            } else if ($action[0] === 'filterBy') {
                $this->internalDataListUpdateAllValuesIfNeeded($data);
                $temp = [];
                foreach ($data as $object) {
                    $propertyName = $action[1];
                    $targetValue = $action[2];
                    $operator = $action[3];
                    $add = false;
                    if (!isset($object->$propertyName)) {
                        if ($operator === 'equal' && $targetValue === null) {
                            $add = true;
                        } elseif ($operator === 'notEqual' && $targetValue !== null) {
                            $add = true;
                        } elseif ($operator === 'inArray' && is_array($targetValue) && array_search(null, $targetValue) !== false) {
                            $add = true;
                        } elseif ($operator === 'notInArray' && !(is_array($targetValue) && array_search(null, $targetValue) !== false)) {
                            $add = true;
                        } else {
                            continue;
                        }
                    }
                    if (!$add) {
                        $value = $object->$propertyName;
                        if ($operator === 'equal') {
                            $add = $value === $targetValue;
                        } elseif ($operator === 'notEqual') {
                            $add = $value !== $targetValue;
                        } elseif ($operator === 'regExp') {
                            $add = preg_match('/' . $targetValue . '/', $value) === 1;
                        } elseif ($operator === 'notRegExp') {
                            $add = preg_match('/' . $targetValue . '/', $value) === 0;
                        } elseif ($operator === 'startWith') {
                            $add = substr($value, 0, strlen($targetValue)) === $targetValue;
                        } elseif ($operator === 'notStartWith') {
                            $add = substr($value, 0, strlen($targetValue)) !== $targetValue;
                        } elseif ($operator === 'endWith') {
                            $add = substr($value, -strlen($targetValue)) === $targetValue;
                        } elseif ($operator === 'notEndWith') {
                            $add = substr($value, -strlen($targetValue)) !== $targetValue;
                        } elseif ($operator === 'inArray') {
                            $add = is_array($targetValue) && array_search($value, $targetValue) !== false;
                        } elseif ($operator === 'notInArray') {
                            $add = !(is_array($targetValue) && array_search($value, $targetValue) !== false);
                        }
                    }
                    if ($add) {
                        $temp[] = $object;
                    }
                }
                $data = $temp;
                unset($temp);
            } elseif ($action[0] === 'sort') {
                $this->internalDataListUpdateAllValuesIfNeeded($data);
                usort($data, $action[1]);
            } elseif ($action[0] === 'sortBy') {
                $this->internalDataListUpdateAllValuesIfNeeded($data);
                $sortData = []; // save the index and the property needed for the sort in a temp array
                foreach ($data as $index => $object) {
                    $sortValue = isset($object->{$action[1]}) ? $object->{$action[1]} : null;
                    if (is_object($sortValue)) {
                        if ($sortValue instanceof \DateTime) {
                            $sortValue = $sortValue->getTimestamp();
                        } else {
                            $sortValue = null;
                        }
                    }
                    $sortData[] = [$index, $sortValue];
                }
                usort($sortData, function($value1SortData, $value2SortData) use ($action) {
                    if ($value1SortData[1] === null && $value2SortData[1] === null) {
                        $result = 0;
                    } else {
                        if ($value1SortData[1] === null) {
                            return $action[2] === 'asc' ? -1 : 1;
                        }
                        if ($value2SortData[1] === null) {
                            return $action[2] === 'asc' ? 1 : -1;
                        }
                        if ((is_int($value1SortData[1]) || is_float($value1SortData[1])) && (is_int($value2SortData[1]) || is_float($value2SortData[1]))) {
                            $result = $value1SortData[1] < $value2SortData[1] ? -1 : 1;
                        } else {
                            $result = strcmp($value1SortData[1], $value2SortData[1]);
                        }
                    }
                    if ($result === 0) { // if the sort property is the same, maintain the order by index
                        return $value1SortData[0] - $value2SortData[0];
                    }
                    return $result * ($action[2] === 'asc' ? 1 : -1);
                });
                $temp = [];
                foreach ($sortData as $sortedValueData) {
                    $temp[] = $data[$sortedValueData[0]];
                }
                unset($sortData);
                $data = $temp;
                unset($temp);
            } elseif ($action[0] === 'reverse') {
                $data = array_reverse($data);
            } elseif ($action[0] === 'shuffle') {
                shuffle($data);
            } elseif ($action[0] === 'map') {
                $this->internalDataListUpdateAllValuesIfNeeded($data);
                $data = array_map($action[1], $data);
            }
        }
        return $data;
    }
410407
public function update(array $data)
    {
        $todolist = Basecamp::todoLists($this->bucket->id)
                            ->update($this->id, $data);

        $this->setAttributes($todolist);

        return $todolist;
    }
283385
public function addData($data, string $opType = null)
    {
        if (!\is_array($data)) {
            $data = [$data];
        }

        foreach ($data as $actionData) {
            if ($actionData instanceof AbstractScript) {
                $this->addScript($actionData, $opType);
            } elseif ($actionData instanceof Document) {
                $this->addDocument($actionData, $opType);
            } else {
                throw new \InvalidArgumentException('Data should be a Document, a Script or an array containing Documents and/or Scripts');
            }
        }

        return $this;
    }
330001
protected function resolveDatatableAction($actions, $row, $element)
    {
        if (!$element instanceof Closure) {
            return false;
        }
        $action = call_user_func($element, $row);
        if (empty($action)) {
            return false;
        }
        $url   = handles(array_get($action, 'url', '#'));
        $title = array_get($action, 'title');
        $link  = app('html')->link($url, $title, array_get($action, 'attributes', []));
        ($actions instanceof Collection) ? $actions->push($link) : array_push($actions, $link);
        return $actions;
    }
39218
public function Order( $data )
	{
		Deprecation::getInstance()->setExceptionVersion( '0.9' )
			->message(  'Use orderBy instad' );
		if( !is_array( $data ) )
			throw new InvalidArgumentException( 'Orders must be given as List of Column and Direction.' );
		$column		= $data[0];
		$direction	= strtoupper( $data[1] );
		$this->builder->addOrder( $column, $direction );
		return array();
	}
980584
private function prepareDataForUpdate(array $data)
	{
		$result = array();
		foreach ($data as $key => $value) {
			$result[$key] = array(
				'Action' => AttributeAction::PUT,
				'Value' => array(
					$this->getValueType($value) => $value
				)
			);
		}
		Debugger::barDump($result);
		return $result;
	}
711575
public function addActions(array $actions)
    {
        collect($actions)->each(function ($action) {
            $this->addAction($action);
        });

        return $this;
    }
451935
public function setCustomActions($name, $data = null)
    {
        $actions = is_array($name) ? $name : [$name => $data];

        foreach ($actions as $key => $value) {
            $this->customActions[$key] = $value;
        }

        return $this;
    }
968839
protected function groupedAssignAction($role, array $actions, $allow = true)
    {
        foreach ($actions as $action) {
            if (!$this->actions->has($action)) {
                throw new InvalidArgumentException("Action {$action} does not exist.");
            }

            $this->assign($role, $action, $allow);
        }

        return true;
    }
504551
public static function applySerializers(array $serializers, $data) {
		return array_reduce($serializers, function ($serializedData, $serializer) {
			return $serializer->apply($serializedData);
		}, $data);
	}
1144698
public function update($data)
  {
    $this->stmt['action'] = 'UPDATE';
    $this->stmt['cols'] = array_merge($this->stmt['cols'], $data);
    return $this;
  }
821352
protected function resolveDatatableAction($actions, $row, $element)
    {
        if (!$element instanceof Closure) {
            return false;
        }
        $action = call_user_func($element, $row);
        $url    = handles(array_get($action, 'url', '#'));
        $title  = array_get($action, 'title');
        $icon   = array_get($action, 'attributes.data-icon');
        $html   = app('html');
        if (strlen($icon)) {
            $title = $html->raw('<i class="zmdi ' . (starts_with($icon, 'zmdi') ? $icon : 'zmdi-' . $icon) . '"></i><span>' . $title . '</span>');
        }
        $attributes = array_get($action, 'attributes', []);
        $this->addClass('mass-action', $attributes);
        $link       = $html->link($url, $title, $attributes);
        ($actions instanceof Collection) ? $actions->push($link) : array_push($actions, $link);
        return $actions;
    }
205875
public function setData($data)
	{
		if ($data && !static::$methods[$this->method]) {
			throw new \InvalidArgumentException("HTTP method [$this->method] does not allow POST data.");
		}

		$this->data = $data;

		return $this;
	}
210716
public function updateData(array $data) {
        foreach($data as $name => $value) {
            $this->data[$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;
    }
317176
public function create(array $data)
    {
        if (isset($data['results'])) {
            return $this->createSearchResults($data['results']);
        } elseif (isset($data['packages'])) {
            return $this->createSearchResults($data['packages']);
        } elseif (isset($data['package'])) {
            return $this->createPackageResults($data['package']);
        } elseif (isset($data['packageNames'])) {
            return $data['packageNames'];
        }

        throw new InvalidArgumentException('Invalid input data.');
    }
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;
    }