Create a Struct from an associative array
@param array $data associative array array('property'=>data)
@param bool $filter (optional) if true, $data array keys which are not defined as properties in the Struct will be ignored
@return Struct
497317
public static function fromArray(array $data, $filter = false){
        $class = get_called_class();
        $object = new static();
        foreach($data as $key => $value){
            if(!$filter || property_exists($class, $key)){
                $object->$key = $value;
            }
        }
        return $object;
    }
979244
public function add($filter)
    {
        if (is_array($filter)) {
            $this->collection[] = new Filter($filter);
        } elseif (is_object($filter) && $filter instanceof Filter) {
            $this->collection[] = $filter;
        }

        return $this;
    }
831263
public static function addFilter($filter, $callback = null)
    {
        if (is_array($filter)) {
            $filters = $filter;
            foreach ($filters as $key => $filter) {
                if (is_numeric($key)) {
                    $key = $filter;
                }
                self::addFilter($key, $filter);
            }

            return true;
        } elseif (is_string($filter) && class_exists($filter, false) && is_subclass_of($filter, 'FilterCollection')) {
            foreach (get_class_methods($filter) as $f) {
                if (is_callable(array($filter, $f))) {
                    self::$filters[$f] = array($filter, $f);
                }
            }

            return true;
        }
        if (is_null($callback)) {
            $callback = $filter;
        }

        if (!is_callable($callback)) {
            return false;
        }
        self::$filters[$filter] = $callback;
    }
735700
protected function filterWalker($filter, $data, $parameters = [])
	{
		$filter = $this->camelCase($filter);
		array_unshift($parameters, $data);

		if (is_array($data) and $this->recursive === true) {
			foreach ($data as $key => $value) {
				$parameters[0] = $value;
				$data[$key] = call_user_func_array([$this, $filter], $parameters);
			}
		} else {
			$data = call_user_func_array(array($this, $filter), $parameters);
		}

		return $data;
	}
714657
private function storeFilterValues(array $data)
    {
        $this->filterValues = $data;

        $session = new Session();

        foreach($this->filters as $datagridFilter) {
            if ($datagridFilter->getType() instanceof DatagridFilterTypeEntity) {
                if (!empty($this->filterValues[$datagridFilter->getName()])) {
                    $this->filterValues[$datagridFilter->getName()] = $this->filterValues[$datagridFilter->getName()]->getId();
                }
            }
        }

        $session->set($this->getStorageNamespace(), $this->filterValues);
    }
570487
public function make($data, $filters, $recursive = true)
	{
		$this->data 		= $data;
		$this->filters 		= $this->explodeFilters($filters);
		$this->recursive 	= $recursive;
		$this->filteredData	= array();

		return $this;
	}
1107361
public static function toArray($object, $group = NULL, $filter = NULL)
	{
		if ($object === null) {
			return null;
		}
		if (!isset(self::$groups[$group])) {
			throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithNoProperty' . '.');
		} else {
			$id = self::$groups[$group];
		}

		if (!($object instanceof ClassWithNoProperty)) {
			throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithNoProperty.');
		}

		if (Stack::$objects === null) {
			Stack::$objects = new \SplObjectStorage();
		}

		if (Stack::$objects->contains($object)) {
			return null;
		}

		Stack::$objects->attach($object);

		try {
			$output = array();

		} catch (\Exception $e) {
			Stack::$objects->detach($object);
			throw $e;
		}

		Stack::$objects->detach($object);
		return $output;
	}
1372091
public function createPayment($data, $filters = [])
    {
        return $this->client->orderPayments->createFor($this, $data, $filters);
    }
251533
public function make($fields, bool $filter = true): CompositableInterface
    {
        $class = $this->defineClass($fields);

        if ($class !== $this->class) {
            //We have to dedicate class creation to external instantiator (possibly children class)
            return $this->odm->make($class, $fields, $filter);
        }

        if (!is_array($fields)) {
            $fields = iterator_to_array($fields);
        }

        //Now we can construct needed class, in this case we are following DocumentEntity declaration
        if (!$filter) {
            //No need to filter values, passing directly in constructor
            return new $class($fields, $this->odm, $this->schema);
        }

        /*
         * Filtering entity
         */
        $entity = new $class([], $this->odm, $this->schema);
        if (!$entity instanceof CompositableInterface) {
            throw new InstantionException(
                "Unable to set filtered values for '{$class}', must be instance of CompositableInterface"
            );
        }

        //Must pass value thought all needed filters
        $entity->setValue($fields);

        return $entity;
    }
1058433
protected function getAssociationsFilter(string $filter = null)
    {
        $mappingConfiguration = new PropertyMappingConfiguration();
        $mappingConfiguration->setTypeConverter($this->typeConverterObjectConverter);
        $mappingConfiguration->setTypeConverterOption(\RGU\Dvoconnector\Property\TypeConverter\ObjectConverter::class, \RGU\Dvoconnector\Property\TypeConverter\ObjectConverter::CONFIGURATION_OBJECT, $this->getDefaultAssociationsFilter());

        return $this->convertAssociationsFilter($mappingConfiguration, $filter);
    }
1026176
public static function create($filter, \SplPriorityQueue $namespaces = null)
    {
        if (class_exists($filter)) {
            return new $filter();
        }

        $namespaces = $namespaces ?: static::getNamespaces();

        foreach ($namespaces as $namespace) {
            $class = trim($namespace, '\\') . '\\' . ucfirst($filter) . 'Filter';

            if (class_exists($class)) {
                return new $class();
            }
        }

        return new DefaultFilter($filter);
    }
151623
public static function createFromArray(array $data)
    {
        $self = new self();

        if (isset($data['id'])) {
            $self->setId($data['id']);
        }
        if (isset($data['name'])) {
            $self->setName($data['name']);
        }
        if (isset($data['plural'])) {
            $self->setPlural($data['plural']);
        }
        if (isset($data['data_type'])) {
            $self->setDataType($data['data_type']);
        }
        if (isset($data['tags'])) {
            $self->setTags($data['tags']);
        }

        return $self;
    }
1013669
public function filter($filter)
    {
        $callback = is_array($filter) ? $this->_filterFromArray($filter) : $filter;
        $data = array_filter($this->_data, $callback);
        return new static($data);
    }
952642
private static function fixFilterFieldPath(?Filter $filter): ? Filter
    {
        if (is_null($filter)) {
            return $filter;
        }

        $filterAsArray = $filter->toArray();
        $filterAsArray['field'] = Item::getPathByField($filterAsArray['field']);

        return Filter::createFromArray($filterAsArray);
    }
747235
public function make($filter)
    {
        if ($filter instanceof Filter)
        {
            return clone $filter;
        }
        
        $filter = isset($this->aliases[$filter]) ? $this->aliases[$filter] : $filter;

        if (is_array($filter))
        {
            list($filter, $callback) = array(current($filter), next($filter));
        }

        // If the filter was aliased and the value of the array was a callable closure then
        // we'll return and fire the callback on the filter instance so that any arguments
        // can be set for the filters constructor.
        $filter = new Filter($this->log, $filter, $this->nodePaths, $this->appEnvironment);

        if (isset($callback) and is_callable($callback))
        {
            call_user_func($callback, $filter);
        }

        return $filter;
    }
621336
protected function _buildNodeInfoObject(array $data)
    {
        $options = $this->getOptions();

        $id = $data[$options->getIdColumnName()];
        $parentId = $data[$options->getParentIdColumnName()];
        $level = (int) $data[$options->getLevelColumnName()];
        $left = (int) $data[$options->getLeftColumnName()];
        $right = (int) $data[$options->getRightColumnName()];

        if (isset($data[$options->getScopeColumnName()])) {
            $scope = $data[$options->getScopeColumnName()];
        } else {
            $scope = null;
        }

        return new NodeInfo($id, $parentId, $level, $left, $right, $scope);
    }
338041
public static function createFromArray(array $data)
    {
        $self = new self();

        if (isset($data['id'])) {
            $self->setId($data['id']);
        }
        if (isset($data['name'])) {
            $self->setName($data['name']);
        }
        if (isset($data['description'])) {
            $self->setDescription($data['description']);
        }
        if (isset($data['name_hash'])) {
            $self->setNameHash($data['name_hash']);
        }
        if (isset($data['plural'])) {
            $self->setPlural($data['plural']);
        }
        if (isset($data['name_plural'])) {
            $self->setNamePlural($data['name_plural']);
        }
        if (isset($data['created_at'])) {
            $self->setCreatedAt($data['created_at']);
        }
        if (isset($data['updated_at'])) {
            $self->setUpdatedAt($data['updated_at']);
        }
        if (isset($data['data_type'])) {
            $self->setDataType($data['data_type']);
        }
        if (isset($data['tags'])) {
            $self->setTags($data['tags']);
        }

        return $self;
    }